{
  "openapi": "3.1.0",
  "info": {
    "title": "Masheev API",
    "description": "Supported Masheev API schemas. Read https://docs.masheev.com/authentication.md and https://docs.masheev.com/capabilities.md before calling operations. Organization API keys use X-API-Key on eligible org-scoped routes; session-only routes require a Masheev session. A schema is not an availability or authorization guarantee.",
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "https://api.masheev.com"
    }
  ],
  "tags": [
    {
      "name": "System",
      "description": "System endpoints"
    },
    {
      "name": "Email",
      "description": "Email endpoints"
    },
    {
      "name": "Admin",
      "description": "Admin endpoints"
    },
    {
      "name": "Outbound",
      "description": "Outbound endpoints"
    },
    {
      "name": "Organization",
      "description": "Organization endpoints"
    },
    {
      "name": "Tracking",
      "description": "Tracking endpoints"
    },
    {
      "name": "Website",
      "description": "Website endpoints"
    },
    {
      "name": "Inboxes",
      "description": "Inboxes endpoints"
    },
    {
      "name": "Contacts",
      "description": "Contacts endpoints"
    },
    {
      "name": "Conversations",
      "description": "Conversations endpoints"
    },
    {
      "name": "Auto-Resolve",
      "description": "Auto-Resolve endpoints"
    },
    {
      "name": "Messages",
      "description": "Messages endpoints"
    },
    {
      "name": "Labels",
      "description": "Labels endpoints"
    },
    {
      "name": "Contact tags",
      "description": "Contact tags endpoints"
    },
    {
      "name": "Lifecycle Stages",
      "description": "Lifecycle Stages endpoints"
    },
    {
      "name": "Notes",
      "description": "Notes endpoints"
    },
    {
      "name": "Escalations",
      "description": "Escalations endpoints"
    },
    {
      "name": "Canned Responses",
      "description": "Canned Responses endpoints"
    },
    {
      "name": "Knowledge",
      "description": "Knowledge endpoints"
    },
    {
      "name": "Phone Numbers",
      "description": "Phone Numbers endpoints"
    },
    {
      "name": "Regulatory Bundles",
      "description": "Regulatory Bundles endpoints"
    },
    {
      "name": "Voices",
      "description": "Voices endpoints"
    },
    {
      "name": "Voice",
      "description": "Voice endpoints"
    },
    {
      "name": "Provider Credentials",
      "description": "Provider Credentials endpoints"
    },
    {
      "name": "Webhooks",
      "description": "Webhooks endpoints"
    },
    {
      "name": "Chat Console",
      "description": "Chat Console endpoints"
    },
    {
      "name": "Files",
      "description": "Files endpoints"
    },
    {
      "name": "Audit Logs",
      "description": "Audit Logs endpoints"
    },
    {
      "name": "Billing",
      "description": "Billing endpoints"
    },
    {
      "name": "Feedback",
      "description": "Feedback endpoints"
    },
    {
      "name": "Auto-Resolve Config",
      "description": "Auto-Resolve Config endpoints"
    },
    {
      "name": "Automations",
      "description": "Automations endpoints"
    },
    {
      "name": "Devices",
      "description": "Devices endpoints"
    },
    {
      "name": "Notifications",
      "description": "Notifications endpoints"
    },
    {
      "name": "Analytics",
      "description": "Analytics endpoints"
    },
    {
      "name": "Events",
      "description": "Events endpoints"
    },
    {
      "name": "Authentication",
      "description": "Authentication endpoints (Better Auth)"
    }
  ],
  "externalDocs": {
    "url": "https://docs.masheev.com"
  },
  "paths": {
    "/api/rpc/health": {
      "get": {
        "operationId": "health",
        "summary": "Health check",
        "description": "Check if the API service is running and healthy",
        "tags": ["System"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string",
                      "const": "ok"
                    },
                    "service": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "string"
                    }
                  },
                  "required": ["status", "service", "timestamp"],
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/emails/preferences": {
      "get": {
        "operationId": "profile-email-preferences-get",
        "summary": "Get user email preferences",
        "description": "Get the current user's email preferences",
        "tags": ["Email"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "userId": {
                      "type": "string"
                    },
                    "topics": {
                      "anyOf": [
                        {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "number"
                            },
                            {
                              "type": "boolean"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        {
                          "type": "object",
                          "propertyNames": {
                            "type": "string"
                          },
                          "additionalProperties": {}
                        },
                        {
                          "type": "array",
                          "items": {}
                        }
                      ]
                    },
                    "frequency": {
                      "type": "string",
                      "enum": ["immediate", "daily", "weekly", "monthly"]
                    },
                    "consentAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "consentIp": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "consentUa": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "appleEmailRelayEnabled": {
                      "anyOf": [
                        {
                          "type": "boolean"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "appleEmailRelayUpdatedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "createdAt": {
                      "type": "string"
                    },
                    "updatedAt": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "userId",
                    "topics",
                    "consentAt",
                    "consentIp",
                    "consentUa",
                    "appleEmailRelayEnabled",
                    "appleEmailRelayUpdatedAt",
                    "createdAt",
                    "updatedAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "profile-email-preferences-update",
        "summary": "Update user email preferences",
        "description": "Update the current user's email preferences",
        "tags": ["Email"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "userId": {
                    "type": "string"
                  },
                  "topics": {
                    "anyOf": [
                      {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "number"
                          },
                          {
                            "type": "boolean"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      {
                        "type": "object",
                        "propertyNames": {
                          "type": "string"
                        },
                        "additionalProperties": {}
                      },
                      {
                        "type": "array",
                        "items": {}
                      }
                    ]
                  },
                  "frequency": {
                    "type": "string",
                    "enum": ["immediate", "daily", "weekly", "monthly"]
                  },
                  "consentAt": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "consentIp": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "consentUa": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "appleEmailRelayEnabled": {
                    "anyOf": [
                      {
                        "type": "boolean"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "appleEmailRelayUpdatedAt": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "createdAt": {
                    "type": "string"
                  },
                  "updatedAt": {
                    "type": "string"
                  }
                },
                "required": ["userId"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "userId": {
                      "type": "string"
                    },
                    "topics": {
                      "anyOf": [
                        {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "number"
                            },
                            {
                              "type": "boolean"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        {
                          "type": "object",
                          "propertyNames": {
                            "type": "string"
                          },
                          "additionalProperties": {}
                        },
                        {
                          "type": "array",
                          "items": {}
                        }
                      ]
                    },
                    "frequency": {
                      "type": "string",
                      "enum": ["immediate", "daily", "weekly", "monthly"]
                    },
                    "consentAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "consentIp": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "consentUa": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "appleEmailRelayEnabled": {
                      "anyOf": [
                        {
                          "type": "boolean"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "appleEmailRelayUpdatedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "createdAt": {
                      "type": "string"
                    },
                    "updatedAt": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "userId",
                    "topics",
                    "consentAt",
                    "consentIp",
                    "consentUa",
                    "appleEmailRelayEnabled",
                    "appleEmailRelayUpdatedAt",
                    "createdAt",
                    "updatedAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/admin/panel-stats": {
      "get": {
        "operationId": "admin-panelStats",
        "summary": "Get admin dashboard statistics",
        "description": "Retrieve comprehensive statistics for the admin dashboard including user counts, organization metrics, and system health data",
        "tags": ["Admin"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "query",
            "name": "timeRange",
            "schema": {
              "default": "this_month",
              "type": "string",
              "enum": [
                "today",
                "yesterday",
                "this_week",
                "last_week",
                "this_month",
                "last_month",
                "this_year",
                "last_year"
              ]
            }
          },
          {
            "in": "query",
            "name": "includeComparison",
            "schema": {
              "default": true,
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "timeRange": {
                      "type": "string"
                    },
                    "comparisonPeriod": {
                      "type": "string"
                    },
                    "users": {
                      "type": "object",
                      "properties": {
                        "total": {
                          "type": "object",
                          "properties": {
                            "current": {
                              "type": "number"
                            },
                            "previous": {
                              "type": "number"
                            },
                            "change": {
                              "type": "number"
                            },
                            "changePercent": {
                              "type": "number"
                            }
                          },
                          "required": ["current", "previous", "change", "changePercent"],
                          "additionalProperties": false
                        },
                        "active": {
                          "type": "object",
                          "properties": {
                            "current": {
                              "type": "number"
                            },
                            "previous": {
                              "type": "number"
                            },
                            "change": {
                              "type": "number"
                            },
                            "changePercent": {
                              "type": "number"
                            }
                          },
                          "required": ["current", "previous", "change", "changePercent"],
                          "additionalProperties": false
                        },
                        "verified": {
                          "type": "object",
                          "properties": {
                            "current": {
                              "type": "number"
                            },
                            "previous": {
                              "type": "number"
                            },
                            "change": {
                              "type": "number"
                            },
                            "changePercent": {
                              "type": "number"
                            }
                          },
                          "required": ["current", "previous", "change", "changePercent"],
                          "additionalProperties": false
                        },
                        "withTwoFactor": {
                          "type": "object",
                          "properties": {
                            "current": {
                              "type": "number"
                            },
                            "previous": {
                              "type": "number"
                            },
                            "change": {
                              "type": "number"
                            },
                            "changePercent": {
                              "type": "number"
                            }
                          },
                          "required": ["current", "previous", "change", "changePercent"],
                          "additionalProperties": false
                        },
                        "banned": {
                          "type": "object",
                          "properties": {
                            "current": {
                              "type": "number"
                            },
                            "previous": {
                              "type": "number"
                            },
                            "change": {
                              "type": "number"
                            },
                            "changePercent": {
                              "type": "number"
                            }
                          },
                          "required": ["current", "previous", "change", "changePercent"],
                          "additionalProperties": false
                        },
                        "new": {
                          "type": "object",
                          "properties": {
                            "current": {
                              "type": "number"
                            },
                            "previous": {
                              "type": "number"
                            },
                            "change": {
                              "type": "number"
                            },
                            "changePercent": {
                              "type": "number"
                            }
                          },
                          "required": ["current", "previous", "change", "changePercent"],
                          "additionalProperties": false
                        }
                      },
                      "required": ["total", "active", "verified", "withTwoFactor", "banned", "new"],
                      "additionalProperties": false
                    },
                    "organizations": {
                      "type": "object",
                      "properties": {
                        "total": {
                          "type": "object",
                          "properties": {
                            "current": {
                              "type": "number"
                            },
                            "previous": {
                              "type": "number"
                            },
                            "change": {
                              "type": "number"
                            },
                            "changePercent": {
                              "type": "number"
                            }
                          },
                          "required": ["current", "previous", "change", "changePercent"],
                          "additionalProperties": false
                        },
                        "withMembers": {
                          "type": "object",
                          "properties": {
                            "current": {
                              "type": "number"
                            },
                            "previous": {
                              "type": "number"
                            },
                            "change": {
                              "type": "number"
                            },
                            "changePercent": {
                              "type": "number"
                            }
                          },
                          "required": ["current", "previous", "change", "changePercent"],
                          "additionalProperties": false
                        },
                        "withTeams": {
                          "type": "object",
                          "properties": {
                            "current": {
                              "type": "number"
                            },
                            "previous": {
                              "type": "number"
                            },
                            "change": {
                              "type": "number"
                            },
                            "changePercent": {
                              "type": "number"
                            }
                          },
                          "required": ["current", "previous", "change", "changePercent"],
                          "additionalProperties": false
                        },
                        "new": {
                          "type": "object",
                          "properties": {
                            "current": {
                              "type": "number"
                            },
                            "previous": {
                              "type": "number"
                            },
                            "change": {
                              "type": "number"
                            },
                            "changePercent": {
                              "type": "number"
                            }
                          },
                          "required": ["current", "previous", "change", "changePercent"],
                          "additionalProperties": false
                        },
                        "averageTeamSize": {
                          "type": "object",
                          "properties": {
                            "current": {
                              "type": "number"
                            },
                            "previous": {
                              "type": "number"
                            },
                            "change": {
                              "type": "number"
                            }
                          },
                          "required": ["current", "previous", "change"],
                          "additionalProperties": false
                        }
                      },
                      "required": ["total", "withMembers", "withTeams", "new", "averageTeamSize"],
                      "additionalProperties": false
                    },
                    "activity": {
                      "type": "object",
                      "properties": {
                        "newSessions": {
                          "type": "object",
                          "properties": {
                            "current": {
                              "type": "number"
                            },
                            "previous": {
                              "type": "number"
                            },
                            "change": {
                              "type": "number"
                            },
                            "changePercent": {
                              "type": "number"
                            }
                          },
                          "required": ["current", "previous", "change", "changePercent"],
                          "additionalProperties": false
                        },
                        "newInvitations": {
                          "type": "object",
                          "properties": {
                            "current": {
                              "type": "number"
                            },
                            "previous": {
                              "type": "number"
                            },
                            "change": {
                              "type": "number"
                            },
                            "changePercent": {
                              "type": "number"
                            }
                          },
                          "required": ["current", "previous", "change", "changePercent"],
                          "additionalProperties": false
                        },
                        "newApiKeys": {
                          "type": "object",
                          "properties": {
                            "current": {
                              "type": "number"
                            },
                            "previous": {
                              "type": "number"
                            },
                            "change": {
                              "type": "number"
                            },
                            "changePercent": {
                              "type": "number"
                            }
                          },
                          "required": ["current", "previous", "change", "changePercent"],
                          "additionalProperties": false
                        }
                      },
                      "required": ["newSessions", "newInvitations", "newApiKeys"],
                      "additionalProperties": false
                    },
                    "engagement": {
                      "type": "object",
                      "properties": {
                        "activeSessions": {
                          "type": "object",
                          "properties": {
                            "current": {
                              "type": "number"
                            },
                            "previous": {
                              "type": "number"
                            },
                            "change": {
                              "type": "number"
                            },
                            "changePercent": {
                              "type": "number"
                            }
                          },
                          "required": ["current", "previous", "change", "changePercent"],
                          "additionalProperties": false
                        },
                        "pendingInvitations": {
                          "type": "object",
                          "properties": {
                            "current": {
                              "type": "number"
                            },
                            "previous": {
                              "type": "number"
                            },
                            "change": {
                              "type": "number"
                            },
                            "changePercent": {
                              "type": "number"
                            }
                          },
                          "required": ["current", "previous", "change", "changePercent"],
                          "additionalProperties": false
                        },
                        "twoFactorAdoption": {
                          "type": "object",
                          "properties": {
                            "current": {
                              "type": "number"
                            },
                            "previous": {
                              "type": "number"
                            },
                            "change": {
                              "type": "number"
                            }
                          },
                          "required": ["current", "previous", "change"],
                          "additionalProperties": false
                        }
                      },
                      "required": ["activeSessions", "pendingInvitations", "twoFactorAdoption"],
                      "additionalProperties": false
                    },
                    "systemHealth": {
                      "type": "object",
                      "properties": {
                        "databaseConnected": {
                          "type": "boolean"
                        },
                        "totalTables": {
                          "type": "number"
                        },
                        "lastUpdated": {
                          "type": "string"
                        }
                      },
                      "required": ["databaseConnected", "totalTables", "lastUpdated"],
                      "additionalProperties": false
                    },
                    "chartData": {
                      "type": "object",
                      "properties": {
                        "overview": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "category": {
                                "type": "string"
                              },
                              "current": {
                                "type": "number"
                              },
                              "previous": {
                                "type": "number"
                              },
                              "change": {
                                "type": "number"
                              }
                            },
                            "required": ["category", "current", "previous", "change"],
                            "additionalProperties": false
                          }
                        },
                        "trends": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "period": {
                                "type": "string"
                              },
                              "users": {
                                "type": "number"
                              },
                              "organizations": {
                                "type": "number"
                              },
                              "sessions": {
                                "type": "number"
                              },
                              "invitations": {
                                "type": "number"
                              }
                            },
                            "required": [
                              "period",
                              "users",
                              "organizations",
                              "sessions",
                              "invitations"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "activityBreakdown": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "metric": {
                                "type": "string"
                              },
                              "value": {
                                "type": "number"
                              },
                              "category": {
                                "type": "string"
                              }
                            },
                            "required": ["metric", "value", "category"],
                            "additionalProperties": false
                          }
                        }
                      },
                      "required": ["overview", "trends", "activityBreakdown"],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "timeRange",
                    "comparisonPeriod",
                    "users",
                    "organizations",
                    "activity",
                    "engagement",
                    "systemHealth",
                    "chartData"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/admin/emails/health": {
      "get": {
        "operationId": "admin-emails-health",
        "summary": "Email system health check",
        "description": "Check email system health and configuration - admin access required",
        "tags": ["Admin", "Email"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string",
                      "enum": ["healthy", "unhealthy"]
                    },
                    "timestamp": {
                      "type": "string",
                      "format": "date-time",
                      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                    },
                    "providers": {
                      "type": "object",
                      "properties": {
                        "email": {
                          "type": "string"
                        }
                      },
                      "required": ["email"],
                      "additionalProperties": false
                    },
                    "config": {
                      "type": "object",
                      "properties": {
                        "provider": {
                          "type": "string"
                        },
                        "trackingEnabled": {
                          "type": "boolean"
                        },
                        "previewEnabled": {
                          "type": "boolean"
                        },
                        "rateLimitWindow": {
                          "type": "integer",
                          "exclusiveMinimum": 0,
                          "maximum": 9007199254740991
                        },
                        "rateLimitMax": {
                          "type": "integer",
                          "exclusiveMinimum": 0,
                          "maximum": 9007199254740991
                        }
                      },
                      "required": [
                        "provider",
                        "trackingEnabled",
                        "previewEnabled",
                        "rateLimitWindow",
                        "rateLimitMax"
                      ],
                      "additionalProperties": false
                    },
                    "systemInfo": {
                      "type": "object",
                      "properties": {
                        "environment": {
                          "type": "string"
                        }
                      },
                      "required": ["environment"],
                      "additionalProperties": false
                    }
                  },
                  "required": ["status", "timestamp", "providers", "config", "systemInfo"],
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/admin/emails/metrics": {
      "get": {
        "operationId": "admin-emails-getMetrics",
        "summary": "Get comprehensive email metrics",
        "description": "Get detailed email analytics across all users - admin access required",
        "tags": ["Admin", "Email"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "query",
            "name": "template",
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "category",
            "schema": {
              "type": "string",
              "enum": ["transactional", "marketing", "security"]
            }
          },
          {
            "in": "query",
            "name": "startDate",
            "schema": {
              "type": "string",
              "format": "date-time",
              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
            }
          },
          {
            "in": "query",
            "name": "endDate",
            "schema": {
              "type": "string",
              "format": "date-time",
              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
            }
          },
          {
            "in": "query",
            "name": "limit",
            "schema": {
              "default": 100,
              "type": "integer",
              "minimum": 1,
              "maximum": 1000
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "timestamp": {
                      "type": "string",
                      "format": "date-time",
                      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                    },
                    "metrics": {
                      "type": "object",
                      "properties": {
                        "totalSent": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 9007199254740991
                        },
                        "totalDelivered": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 9007199254740991
                        },
                        "totalOpened": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 9007199254740991
                        },
                        "totalClicked": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 9007199254740991
                        },
                        "totalBounced": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 9007199254740991
                        },
                        "totalComplaints": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 9007199254740991
                        },
                        "totalFailed": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 9007199254740991
                        },
                        "uniqueOpens": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 9007199254740991
                        },
                        "uniqueClicks": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 9007199254740991
                        },
                        "deliveryRate": {
                          "type": "number",
                          "minimum": 0,
                          "maximum": 100
                        },
                        "openRate": {
                          "type": "number",
                          "minimum": 0,
                          "maximum": 100
                        },
                        "clickRate": {
                          "type": "number",
                          "minimum": 0,
                          "maximum": 100
                        },
                        "bounceRate": {
                          "type": "number",
                          "minimum": 0,
                          "maximum": 100
                        },
                        "complaintRate": {
                          "type": "number",
                          "minimum": 0,
                          "maximum": 100
                        }
                      },
                      "required": [
                        "totalSent",
                        "totalDelivered",
                        "totalOpened",
                        "totalClicked",
                        "totalBounced",
                        "totalComplaints",
                        "totalFailed",
                        "uniqueOpens",
                        "uniqueClicks",
                        "deliveryRate",
                        "openRate",
                        "clickRate",
                        "bounceRate",
                        "complaintRate"
                      ],
                      "additionalProperties": false
                    },
                    "providers": {
                      "type": "object",
                      "properties": {
                        "email": {
                          "type": "string"
                        }
                      },
                      "required": ["email"],
                      "additionalProperties": false
                    },
                    "breakdown": {
                      "type": "object",
                      "properties": {
                        "byTemplate": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "group": {
                                "type": "string"
                              },
                              "totalSent": {
                                "type": "integer",
                                "minimum": 0,
                                "maximum": 9007199254740991
                              },
                              "totalDelivered": {
                                "type": "integer",
                                "minimum": 0,
                                "maximum": 9007199254740991
                              },
                              "totalOpened": {
                                "type": "integer",
                                "minimum": 0,
                                "maximum": 9007199254740991
                              },
                              "totalClicked": {
                                "type": "integer",
                                "minimum": 0,
                                "maximum": 9007199254740991
                              },
                              "deliveryRate": {
                                "type": "number",
                                "minimum": 0,
                                "maximum": 100
                              },
                              "openRate": {
                                "type": "number",
                                "minimum": 0,
                                "maximum": 100
                              },
                              "clickRate": {
                                "type": "number",
                                "minimum": 0,
                                "maximum": 100
                              }
                            },
                            "required": [
                              "group",
                              "totalSent",
                              "totalDelivered",
                              "totalOpened",
                              "totalClicked",
                              "deliveryRate",
                              "openRate",
                              "clickRate"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "byCategory": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "group": {
                                "type": "string"
                              },
                              "totalSent": {
                                "type": "integer",
                                "minimum": 0,
                                "maximum": 9007199254740991
                              },
                              "totalDelivered": {
                                "type": "integer",
                                "minimum": 0,
                                "maximum": 9007199254740991
                              },
                              "totalOpened": {
                                "type": "integer",
                                "minimum": 0,
                                "maximum": 9007199254740991
                              },
                              "totalClicked": {
                                "type": "integer",
                                "minimum": 0,
                                "maximum": 9007199254740991
                              },
                              "deliveryRate": {
                                "type": "number",
                                "minimum": 0,
                                "maximum": 100
                              },
                              "openRate": {
                                "type": "number",
                                "minimum": 0,
                                "maximum": 100
                              },
                              "clickRate": {
                                "type": "number",
                                "minimum": 0,
                                "maximum": 100
                              }
                            },
                            "required": [
                              "group",
                              "totalSent",
                              "totalDelivered",
                              "totalOpened",
                              "totalClicked",
                              "deliveryRate",
                              "openRate",
                              "clickRate"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "byDay": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "group": {
                                "type": "string"
                              },
                              "totalSent": {
                                "type": "integer",
                                "minimum": 0,
                                "maximum": 9007199254740991
                              },
                              "totalDelivered": {
                                "type": "integer",
                                "minimum": 0,
                                "maximum": 9007199254740991
                              },
                              "totalOpened": {
                                "type": "integer",
                                "minimum": 0,
                                "maximum": 9007199254740991
                              },
                              "totalClicked": {
                                "type": "integer",
                                "minimum": 0,
                                "maximum": 9007199254740991
                              },
                              "deliveryRate": {
                                "type": "number",
                                "minimum": 0,
                                "maximum": 100
                              },
                              "openRate": {
                                "type": "number",
                                "minimum": 0,
                                "maximum": 100
                              },
                              "clickRate": {
                                "type": "number",
                                "minimum": 0,
                                "maximum": 100
                              }
                            },
                            "required": [
                              "group",
                              "totalSent",
                              "totalDelivered",
                              "totalOpened",
                              "totalClicked",
                              "deliveryRate",
                              "openRate",
                              "clickRate"
                            ],
                            "additionalProperties": false
                          }
                        }
                      },
                      "required": ["byTemplate", "byCategory", "byDay"],
                      "additionalProperties": false
                    }
                  },
                  "required": ["timestamp", "metrics", "providers", "breakdown"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/admin/emails/analytics/clicks": {
      "get": {
        "operationId": "admin-emails-getClickAnalytics",
        "summary": "Get email click analytics",
        "description": "Get detailed click analytics for email campaigns - admin access required",
        "tags": ["Admin", "Email"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "query",
            "name": "template",
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "category",
            "schema": {
              "type": "string",
              "enum": ["transactional", "marketing", "security"]
            }
          },
          {
            "in": "query",
            "name": "startDate",
            "schema": {
              "type": "string",
              "format": "date-time",
              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
            }
          },
          {
            "in": "query",
            "name": "endDate",
            "schema": {
              "type": "string",
              "format": "date-time",
              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
            }
          },
          {
            "in": "query",
            "name": "limit",
            "schema": {
              "default": 100,
              "type": "integer",
              "minimum": 1,
              "maximum": 1000
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "totalClicks": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 9007199254740991
                    },
                    "uniqueClicks": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 9007199254740991
                    },
                    "topUrls": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "url": {
                            "type": "string",
                            "format": "uri"
                          },
                          "clicks": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 9007199254740991
                          },
                          "uniqueClicks": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 9007199254740991
                          },
                          "firstClickedAt": {
                            "type": "string",
                            "format": "date-time",
                            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                          },
                          "lastClickedAt": {
                            "type": "string",
                            "format": "date-time",
                            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                          }
                        },
                        "required": [
                          "url",
                          "clicks",
                          "uniqueClicks",
                          "firstClickedAt",
                          "lastClickedAt"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "clicksByTemplate": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "template": {
                            "type": "string"
                          },
                          "clicks": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 9007199254740991
                          },
                          "uniqueClicks": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 9007199254740991
                          }
                        },
                        "required": ["template", "clicks", "uniqueClicks"],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": ["totalClicks", "uniqueClicks", "topUrls", "clicksByTemplate"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/admin/emails/test": {
      "post": {
        "operationId": "admin-emails-sendTest",
        "summary": "Send test email",
        "description": "Send a test email to verify system functionality - admin access required",
        "tags": ["Admin", "Email"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "operationId": {
                    "type": "string",
                    "format": "uuid",
                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                  },
                  "to": {
                    "type": "string",
                    "format": "email",
                    "pattern": "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
                  },
                  "template": {
                    "type": "string"
                  },
                  "props": {
                    "type": "object",
                    "propertyNames": {
                      "type": "string"
                    },
                    "additionalProperties": {}
                  },
                  "category": {
                    "type": "string",
                    "enum": ["transactional", "marketing", "security"]
                  }
                },
                "required": ["operationId", "to", "template"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "message": {
                      "type": "string"
                    },
                    "emailId": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "string"
                    }
                  },
                  "required": ["success", "message", "timestamp"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/admin/emails/preview": {
      "post": {
        "operationId": "admin-emails-previewTemplate",
        "summary": "Preview email template",
        "description": "Generate email template preview with sample data - admin access required",
        "tags": ["Admin", "Email"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "template": {
                    "type": "string"
                  },
                  "props": {
                    "type": "object",
                    "propertyNames": {
                      "type": "string"
                    },
                    "additionalProperties": {}
                  },
                  "format": {
                    "default": "both",
                    "type": "string",
                    "enum": ["html", "text", "both"]
                  }
                },
                "required": ["template", "props"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "template": {
                      "type": "string"
                    },
                    "subject": {
                      "type": "string"
                    },
                    "html": {
                      "type": "string"
                    },
                    "text": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "string"
                    }
                  },
                  "required": ["template", "subject", "timestamp"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/outbound/admin/snapshots": {
      "get": {
        "operationId": "admin-outbound-snapshots",
        "summary": "Review uncertain outbound snapshot resources",
        "tags": ["Outbound"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "resources": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "orgId": {
                            "type": "string"
                          },
                          "campaignId": {
                            "type": "string"
                          },
                          "variantId": {
                            "type": "string"
                          },
                          "workspace": {
                            "type": "string",
                            "enum": ["platform", "byok"]
                          },
                          "state": {
                            "type": "string",
                            "enum": ["creating", "uncertain"]
                          },
                          "credentialId": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "snapshotHash": {
                            "type": "string"
                          },
                          "agentId": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "createdAt": {
                            "type": "string"
                          },
                          "instruction": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "id",
                          "orgId",
                          "campaignId",
                          "variantId",
                          "workspace",
                          "state",
                          "credentialId",
                          "snapshotHash",
                          "agentId",
                          "createdAt",
                          "instruction"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "unavailableRegions": {
                      "type": "number"
                    }
                  },
                  "required": ["resources", "unavailableRegions"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/outbound/admin/snapshots/{resourceId}/reconcile": {
      "post": {
        "operationId": "admin-outbound-reconcileSnapshot",
        "summary": "Bind an owned provider agent to an uncertain frozen snapshot",
        "tags": ["Outbound"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "resourceId",
            "schema": {
              "type": "string",
              "format": "uuid",
              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
            },
            "required": true
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "agentId": {
                    "type": "string",
                    "pattern": "^[A-Za-z0-9_-]{1,128}$"
                  },
                  "note": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 1000
                  }
                },
                "required": ["orgId", "agentId", "note"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "state": {
                      "type": "string",
                      "enum": ["ready", "retired"]
                    },
                    "needsCampaignReview": {
                      "type": "boolean"
                    }
                  },
                  "required": ["id", "state", "needsCampaignReview"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/outbound/admin/requests": {
      "get": {
        "operationId": "admin-outbound-requests",
        "summary": "Pending outbound limit review queue",
        "tags": ["Outbound"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "requests": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "orgId": {
                            "type": "string"
                          },
                          "idempotencyKey": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "limitKey": {
                            "type": "string",
                            "enum": [
                              "concurrentCalls",
                              "callsPerDay",
                              "requestsPerCampaign",
                              "testNumbers"
                            ]
                          },
                          "currentValue": {
                            "type": "number"
                          },
                          "requestedValue": {
                            "type": "number"
                          },
                          "justification": {
                            "type": "string"
                          },
                          "status": {
                            "type": "string",
                            "enum": ["pending", "approved", "rejected", "canceled"]
                          },
                          "decidedValue": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "consentSampleChecked": {
                            "anyOf": [
                              {
                                "type": "boolean"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "reviewerId": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "reviewNote": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "createdBy": {
                            "type": "string"
                          },
                          "createdAt": {
                            "type": "string"
                          },
                          "decidedAt": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "appliedAt": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "notifiedAt": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        },
                        "required": [
                          "id",
                          "orgId",
                          "idempotencyKey",
                          "limitKey",
                          "currentValue",
                          "requestedValue",
                          "justification",
                          "status",
                          "decidedValue",
                          "consentSampleChecked",
                          "reviewerId",
                          "reviewNote",
                          "createdBy",
                          "createdAt",
                          "decidedAt",
                          "appliedAt",
                          "notifiedAt"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "unavailableRegions": {
                      "type": "number"
                    }
                  },
                  "required": ["requests", "unavailableRegions"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/outbound/admin/requests/{id}/decide": {
      "post": {
        "operationId": "admin-outbound-decide",
        "summary": "Approve or reject an outbound limit increase",
        "tags": ["Outbound"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "decision": {
                    "type": "string",
                    "enum": ["approved", "rejected"]
                  },
                  "value": {
                    "type": "integer",
                    "exclusiveMinimum": 0,
                    "maximum": 9007199254740991
                  },
                  "note": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 2000
                  },
                  "consentSampleChecked": {
                    "type": "boolean"
                  }
                },
                "required": ["orgId", "decision", "note"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "orgId": {
                      "type": "string"
                    },
                    "idempotencyKey": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "limitKey": {
                      "type": "string",
                      "enum": [
                        "concurrentCalls",
                        "callsPerDay",
                        "requestsPerCampaign",
                        "testNumbers"
                      ]
                    },
                    "currentValue": {
                      "type": "number"
                    },
                    "requestedValue": {
                      "type": "number"
                    },
                    "justification": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string",
                      "enum": ["pending", "approved", "rejected", "canceled"]
                    },
                    "decidedValue": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "consentSampleChecked": {
                      "anyOf": [
                        {
                          "type": "boolean"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "reviewerId": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "reviewNote": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "createdBy": {
                      "type": "string"
                    },
                    "createdAt": {
                      "type": "string"
                    },
                    "decidedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "appliedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "notifiedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": [
                    "id",
                    "orgId",
                    "idempotencyKey",
                    "limitKey",
                    "currentValue",
                    "requestedValue",
                    "justification",
                    "status",
                    "decidedValue",
                    "consentSampleChecked",
                    "reviewerId",
                    "reviewNote",
                    "createdBy",
                    "createdAt",
                    "decidedAt",
                    "appliedAt",
                    "notifiedAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/outbound/admin/seller-identity": {
      "post": {
        "operationId": "admin-outbound-verifySellerIdentity",
        "summary": "Verify the workspace calling seller identity",
        "tags": ["Outbound"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "sellerName": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 120
                  },
                  "addressOrFreephone": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "note": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 1000
                  }
                },
                "required": ["orgId", "sellerName", "note"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "sellerName": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 120
                    },
                    "addressOrFreephone": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 200
                    },
                    "verifiedBy": {
                      "type": "string",
                      "minLength": 1
                    },
                    "verifiedAt": {
                      "type": "string",
                      "format": "date-time",
                      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                    },
                    "note": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 1000
                    }
                  },
                  "required": ["sellerName", "verifiedBy", "verifiedAt", "note"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/outbound/admin/health": {
      "get": {
        "operationId": "admin-outbound-health",
        "summary": "Get regional outbound queues, capacity and scheduler health",
        "tags": ["Outbound"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "regions": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "region": {
                            "type": "string",
                            "enum": ["eu", "us-east"]
                          },
                          "queued": {
                            "type": "number"
                          },
                          "due": {
                            "type": "number"
                          },
                          "dialingAgeMs": {
                            "type": "number"
                          },
                          "stuck": {
                            "type": "number"
                          },
                          "platformLive": {
                            "type": "number"
                          },
                          "platformCap": {
                            "type": "number"
                          },
                          "cps": {
                            "type": "number"
                          },
                          "lastTick": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "schedulerUnavailable": {
                            "type": "boolean"
                          }
                        },
                        "required": [
                          "region",
                          "queued",
                          "due",
                          "dialingAgeMs",
                          "stuck",
                          "platformLive",
                          "platformCap",
                          "cps",
                          "lastTick",
                          "schedulerUnavailable"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "unavailableRegions": {
                      "type": "number"
                    }
                  },
                  "required": ["regions", "unavailableRegions"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/outbound/admin/limits": {
      "post": {
        "operationId": "admin-outbound-setLimits",
        "summary": "Set bounded workspace outbound calling limits",
        "tags": ["Outbound"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "limits": {
                    "type": "object",
                    "properties": {
                      "concurrentCalls": {
                        "type": "integer",
                        "minimum": 1,
                        "maximum": 50
                      },
                      "callsPerDay": {
                        "type": "integer",
                        "minimum": 1,
                        "maximum": 20000
                      },
                      "requestsPerCampaign": {
                        "type": "integer",
                        "minimum": 1,
                        "maximum": 100000
                      },
                      "testNumbers": {
                        "type": "integer",
                        "minimum": 1,
                        "maximum": 10
                      }
                    },
                    "additionalProperties": false
                  },
                  "note": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 1000
                  }
                },
                "required": ["orgId", "limits", "note"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "const": true
                    }
                  },
                  "required": ["ok"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/outbound/admin/beta": {
      "post": {
        "operationId": "admin-outbound-setOrgBeta",
        "summary": "Enable or disable outbound beta for a workspace",
        "tags": ["Outbound"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "enabled": {
                    "type": "boolean"
                  }
                },
                "required": ["orgId", "enabled"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "const": true
                    }
                  },
                  "required": ["ok"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/outbound/admin/suspend": {
      "post": {
        "operationId": "admin-outbound-suspend",
        "summary": "Suspend outbound calling and pause active workspace campaigns",
        "tags": ["Outbound"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "reason": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 500
                  }
                },
                "required": ["orgId", "reason"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "const": true
                    }
                  },
                  "required": ["ok"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/outbound/admin/resume": {
      "post": {
        "operationId": "admin-outbound-resume",
        "summary": "Lift workspace suspension while keeping campaigns paused",
        "tags": ["Outbound"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string",
                    "minLength": 1
                  }
                },
                "required": ["orgId"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "const": true
                    }
                  },
                  "required": ["ok"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/outbound/admin/kill-all": {
      "post": {
        "operationId": "admin-outbound-killAll",
        "summary": "Stop outbound calling platform-wide",
        "tags": ["Outbound"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "reason": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 500
                  },
                  "includeInProgress": {
                    "type": "boolean"
                  }
                },
                "required": ["reason"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "const": true
                    }
                  },
                  "required": ["ok"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/outbound/admin/unkill-all": {
      "post": {
        "operationId": "admin-outbound-unkillAll",
        "summary": "Lift the platform-wide outbound stop",
        "tags": ["Outbound"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {}
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "const": true
                    }
                  },
                  "required": ["ok"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/outbound/admin/consent-sources": {
      "get": {
        "operationId": "admin-outbound-consentSources",
        "summary": "Review the consent source queue across workspaces",
        "tags": ["Outbound"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "query",
            "name": "status",
            "schema": {
              "type": "string",
              "enum": ["pending", "approved", "rejected"]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "sources": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "captureChannel": {
                            "type": "string",
                            "enum": ["web_form", "paper", "email", "phone", "in_person", "api"]
                          },
                          "disclosureText": {
                            "type": "string"
                          },
                          "url": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "sellerName": {
                            "type": "string"
                          },
                          "answers": {
                            "type": "object",
                            "properties": {
                              "signedOrTicked": {
                                "type": "boolean"
                              },
                              "namesSellerAndAutomatedCalls": {
                                "type": "boolean"
                              },
                              "askedToBeCalled": {
                                "type": "boolean"
                              }
                            },
                            "required": [
                              "signedOrTicked",
                              "namesSellerAndAutomatedCalls",
                              "askedToBeCalled"
                            ],
                            "additionalProperties": false
                          },
                          "derivedBasis": {
                            "type": "string",
                            "enum": [
                              "express_written",
                              "express_recorded",
                              "inquiry_callback",
                              "existing_customer",
                              "transaction"
                            ]
                          },
                          "coversAutomatedCalls": {
                            "type": "boolean"
                          },
                          "status": {
                            "type": "string",
                            "enum": ["pending", "approved", "rejected"]
                          },
                          "reviewNote": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "createdAt": {
                            "type": "string"
                          },
                          "orgId": {
                            "type": "string"
                          },
                          "orgName": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        },
                        "required": [
                          "id",
                          "name",
                          "captureChannel",
                          "disclosureText",
                          "url",
                          "sellerName",
                          "answers",
                          "derivedBasis",
                          "coversAutomatedCalls",
                          "status",
                          "reviewNote",
                          "createdAt",
                          "orgId",
                          "orgName"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "unavailableRegions": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 9007199254740991
                    }
                  },
                  "required": ["sources", "unavailableRegions"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/outbound/admin/consent-sources/review": {
      "post": {
        "operationId": "admin-outbound-reviewConsentSource",
        "summary": "Approve or reject a pending consent source",
        "tags": ["Outbound"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "sourceId": {
                    "type": "string",
                    "pattern": "^ocs_[0-7][0-9a-hjkmnp-tv-z]{25}$"
                  },
                  "decision": {
                    "type": "string",
                    "enum": ["approved", "rejected"]
                  },
                  "note": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 1000
                  }
                },
                "required": ["sourceId", "decision", "note"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string",
                      "enum": ["approved", "rejected"]
                    }
                  },
                  "required": ["id", "status"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/outbound/admin/suppression": {
      "post": {
        "operationId": "admin-outbound-suppressPlatformWide",
        "summary": "Suppress a number platform-wide in every region",
        "tags": ["Outbound"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "phone": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 64
                  },
                  "note": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 500
                  }
                },
                "required": ["phone", "note"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "phone": {
                      "type": "string"
                    },
                    "regions": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "region": {
                            "type": "string"
                          },
                          "status": {
                            "type": "string",
                            "enum": ["added", "already_suppressed", "unavailable"]
                          }
                        },
                        "required": ["region", "status"],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": ["phone", "regions"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/org/panel-stats": {
      "get": {
        "operationId": "org-panelStats",
        "summary": "Get organization dashboard statistics",
        "description": "Retrieve comprehensive statistics for a specific organization including member counts, team metrics, and activity data",
        "tags": ["Organization"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "required": true
          },
          {
            "in": "query",
            "name": "timeRange",
            "schema": {
              "default": "this_month",
              "type": "string",
              "enum": [
                "today",
                "yesterday",
                "this_week",
                "last_week",
                "this_month",
                "last_month",
                "this_year",
                "last_year"
              ]
            }
          },
          {
            "in": "query",
            "name": "includeComparison",
            "schema": {
              "default": true,
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "timeRange": {
                      "type": "string"
                    },
                    "comparisonPeriod": {
                      "type": "string"
                    },
                    "members": {
                      "type": "object",
                      "properties": {
                        "current": {
                          "type": "number"
                        },
                        "previous": {
                          "type": "number"
                        },
                        "changePercent": {
                          "type": "number"
                        }
                      },
                      "required": ["current", "previous", "changePercent"],
                      "additionalProperties": false
                    },
                    "teams": {
                      "type": "object",
                      "properties": {
                        "current": {
                          "type": "number"
                        },
                        "previous": {
                          "type": "number"
                        },
                        "changePercent": {
                          "type": "number"
                        }
                      },
                      "required": ["current", "previous", "changePercent"],
                      "additionalProperties": false
                    },
                    "activity": {
                      "type": "object",
                      "properties": {
                        "sessionsThisPeriod": {
                          "type": "number"
                        },
                        "invitationsThisPeriod": {
                          "type": "number"
                        },
                        "pendingInvitations": {
                          "type": "number"
                        }
                      },
                      "required": [
                        "sessionsThisPeriod",
                        "invitationsThisPeriod",
                        "pendingInvitations"
                      ],
                      "additionalProperties": false
                    },
                    "summary": {
                      "type": "object",
                      "properties": {
                        "totalMembers": {
                          "type": "number"
                        },
                        "totalTeams": {
                          "type": "number"
                        },
                        "averageTeamSize": {
                          "type": "number"
                        }
                      },
                      "required": ["totalMembers", "totalTeams", "averageTeamSize"],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "timeRange",
                    "comparisonPeriod",
                    "members",
                    "teams",
                    "activity",
                    "summary"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/emails/tracking/view": {
      "get": {
        "operationId": "emails-view",
        "summary": "Track email view",
        "description": "Track when an email is viewed/opened with token validation",
        "tags": ["Email", "Tracking"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "query",
            "name": "emailId",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "token",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "userId",
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "ipAddress",
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "userAgent",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    }
                  },
                  "required": ["success"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/emails/tracking/click": {
      "get": {
        "operationId": "emails-click",
        "summary": "Track email click",
        "description": "Track when a link in an email is clicked with token validation",
        "tags": ["Email", "Tracking"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "query",
            "name": "emailId",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "token",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "userId",
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "ipAddress",
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "userAgent",
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "url",
            "schema": {
              "type": "string",
              "format": "uri"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "linkText",
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "position",
            "schema": {
              "type": "integer",
              "exclusiveMinimum": 0,
              "maximum": 9007199254740991
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "redirectUrl": {
                      "type": "string",
                      "format": "uri"
                    },
                    "success": {
                      "type": "boolean"
                    }
                  },
                  "required": ["redirectUrl", "success"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/emails/tracking/unsubscribe": {
      "post": {
        "operationId": "emails-unsubscribe",
        "summary": "Unsubscribe from emails",
        "description": "Unsubscribe from emails using a JWT token",
        "tags": ["Email", "Tracking"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "topics": {
                    "anyOf": [
                      {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "number"
                          },
                          {
                            "type": "boolean"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      {
                        "type": "object",
                        "propertyNames": {
                          "type": "string"
                        },
                        "additionalProperties": {}
                      },
                      {
                        "type": "array",
                        "items": {}
                      }
                    ]
                  },
                  "token": {
                    "type": "string"
                  }
                },
                "required": ["topics", "token"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "userId": {
                      "type": "string"
                    },
                    "topics": {
                      "anyOf": [
                        {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "number"
                            },
                            {
                              "type": "boolean"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        {
                          "type": "object",
                          "propertyNames": {
                            "type": "string"
                          },
                          "additionalProperties": {}
                        },
                        {
                          "type": "array",
                          "items": {}
                        }
                      ]
                    },
                    "frequency": {
                      "type": "string",
                      "enum": ["immediate", "daily", "weekly", "monthly"]
                    },
                    "consentAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "consentIp": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "consentUa": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "appleEmailRelayEnabled": {
                      "anyOf": [
                        {
                          "type": "boolean"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "appleEmailRelayUpdatedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "createdAt": {
                      "type": "string"
                    },
                    "updatedAt": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "userId",
                    "topics",
                    "consentAt",
                    "consentIp",
                    "consentUa",
                    "appleEmailRelayEnabled",
                    "appleEmailRelayUpdatedAt",
                    "createdAt",
                    "updatedAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/website/contact": {
      "post": {
        "operationId": "website-submitContactForm",
        "summary": "Submit contact form",
        "tags": ["Website"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "operationId": {
                    "type": "string",
                    "format": "uuid",
                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                  },
                  "firstName": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 50
                  },
                  "lastName": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 50
                  },
                  "email": {
                    "type": "string",
                    "format": "email",
                    "pattern": "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
                  },
                  "company": {
                    "type": "string"
                  },
                  "inquiryType": {
                    "type": "string",
                    "enum": ["sales", "support", "partnership", "other"]
                  },
                  "message": {
                    "type": "string",
                    "minLength": 10,
                    "maxLength": 2000
                  },
                  "ref": {
                    "type": "string",
                    "enum": ["starter", "growth", "enterprise", "nav", "roi-calculator"]
                  },
                  "start": {
                    "type": "boolean"
                  },
                  "consent": {
                    "type": "boolean",
                    "const": true
                  },
                  "turnstileToken": {
                    "type": "string",
                    "minLength": 1
                  }
                },
                "required": [
                  "operationId",
                  "firstName",
                  "lastName",
                  "email",
                  "inquiryType",
                  "message",
                  "consent",
                  "turnstileToken"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    }
                  },
                  "required": ["success"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/inboxes": {
      "get": {
        "operationId": "inboxes-list",
        "summary": "List inboxes",
        "tags": ["Inboxes"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "channel",
            "schema": {
              "type": "string",
              "enum": ["voice", "sms", "whatsapp", "chat", "email", "instagram", "google_reviews"]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "inboxes": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "orgId": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "channel": {
                            "type": "string",
                            "enum": [
                              "voice",
                              "sms",
                              "whatsapp",
                              "chat",
                              "email",
                              "instagram",
                              "google_reviews"
                            ]
                          },
                          "status": {
                            "type": "string",
                            "enum": ["active", "paused", "disabled"]
                          },
                          "channelConfig": {
                            "default": {},
                            "anyOf": [
                              {
                                "type": "object",
                                "properties": {
                                  "channel": {
                                    "type": "string",
                                    "const": "voice"
                                  },
                                  "phoneNumber": {
                                    "type": "string"
                                  },
                                  "twilioPhoneNumberSid": {
                                    "type": "string"
                                  },
                                  "elevenlabsAgentId": {
                                    "type": "string"
                                  },
                                  "maxConcurrentCalls": {
                                    "default": 5,
                                    "type": "integer",
                                    "minimum": -9007199254740991,
                                    "maximum": 9007199254740991
                                  },
                                  "recordCalls": {
                                    "default": false,
                                    "type": "boolean"
                                  }
                                },
                                "required": [
                                  "channel",
                                  "phoneNumber",
                                  "twilioPhoneNumberSid",
                                  "maxConcurrentCalls",
                                  "recordCalls"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "channel": {
                                    "type": "string",
                                    "const": "sms"
                                  },
                                  "phoneNumber": {
                                    "type": "string"
                                  },
                                  "twilioPhoneNumberSid": {
                                    "type": "string"
                                  }
                                },
                                "required": ["channel", "phoneNumber", "twilioPhoneNumberSid"],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "channel": {
                                    "type": "string",
                                    "const": "whatsapp"
                                  },
                                  "metaPhoneNumberId": {
                                    "type": "string"
                                  },
                                  "phoneNumber": {
                                    "type": "string"
                                  },
                                  "phoneNumberDisplayName": {
                                    "type": "string"
                                  },
                                  "whatsappBusinessAccountId": {
                                    "type": "string"
                                  },
                                  "facebookPageId": {
                                    "type": "string"
                                  }
                                },
                                "required": ["channel", "metaPhoneNumberId", "phoneNumber"],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "channel": {
                                    "type": "string",
                                    "const": "chat"
                                  },
                                  "widgetId": {
                                    "type": "string"
                                  },
                                  "allowedOrigins": {
                                    "type": "array",
                                    "items": {
                                      "type": "string"
                                    }
                                  },
                                  "theme": {
                                    "type": "object",
                                    "properties": {
                                      "primaryColor": {
                                        "type": "string"
                                      },
                                      "position": {
                                        "type": "string",
                                        "enum": ["bottom-right", "bottom-left"]
                                      },
                                      "template": {
                                        "type": "string"
                                      },
                                      "backgroundColor": {
                                        "type": "string"
                                      },
                                      "textColor": {
                                        "type": "string"
                                      },
                                      "userBubbleColor": {
                                        "type": "string"
                                      },
                                      "userBubbleTextColor": {
                                        "type": "string"
                                      },
                                      "fontFamily": {
                                        "type": "string"
                                      },
                                      "fontSize": {
                                        "type": "string",
                                        "enum": ["sm", "base", "lg"]
                                      },
                                      "messageStyle": {
                                        "type": "string",
                                        "enum": ["plain", "bubble"]
                                      },
                                      "logoUrl": {
                                        "type": "string"
                                      },
                                      "headerTitle": {
                                        "type": "string"
                                      },
                                      "poweredBy": {
                                        "type": "boolean"
                                      }
                                    },
                                    "additionalProperties": false
                                  },
                                  "privacyPolicyUrl": {
                                    "type": "string",
                                    "maxLength": 2048,
                                    "format": "uri"
                                  },
                                  "identityVerificationConfigured": {
                                    "type": "boolean"
                                  }
                                },
                                "required": ["channel"],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "channel": {
                                    "type": "string",
                                    "const": "email"
                                  },
                                  "provider": {
                                    "default": "smtp",
                                    "type": "string",
                                    "enum": ["smtp", "gmail", "microsoft"]
                                  },
                                  "emailAddress": {
                                    "type": "string",
                                    "format": "email",
                                    "pattern": "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
                                  },
                                  "inboundAddress": {
                                    "type": "string",
                                    "format": "email",
                                    "pattern": "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
                                  },
                                  "fromName": {
                                    "type": "string"
                                  },
                                  "replyTo": {
                                    "type": "string",
                                    "format": "email",
                                    "pattern": "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
                                  },
                                  "sendingDomain": {
                                    "type": "string"
                                  },
                                  "dns": {
                                    "type": "object",
                                    "properties": {
                                      "spf": {
                                        "default": "pending",
                                        "type": "string",
                                        "enum": ["pending", "verified", "failing"]
                                      },
                                      "dkim": {
                                        "default": "pending",
                                        "type": "string",
                                        "enum": ["pending", "verified", "failing"]
                                      },
                                      "dmarc": {
                                        "default": "pending",
                                        "type": "string",
                                        "enum": ["pending", "verified", "failing"]
                                      }
                                    },
                                    "required": ["spf", "dkim", "dmarc"],
                                    "additionalProperties": false
                                  },
                                  "credentialId": {
                                    "type": "string"
                                  },
                                  "syncedLabelIds": {
                                    "type": "array",
                                    "items": {
                                      "type": "string"
                                    }
                                  },
                                  "syncedFolderIds": {
                                    "type": "array",
                                    "items": {
                                      "type": "string"
                                    }
                                  }
                                },
                                "required": ["channel", "provider", "emailAddress"],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "channel": {
                                    "type": "string",
                                    "const": "instagram"
                                  },
                                  "instagramBusinessAccountId": {
                                    "type": "string"
                                  },
                                  "instagramPageId": {
                                    "type": "string"
                                  },
                                  "instagramUsername": {
                                    "type": "string"
                                  }
                                },
                                "required": [
                                  "channel",
                                  "instagramBusinessAccountId",
                                  "instagramPageId"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "channel": {
                                    "type": "string",
                                    "const": "google_reviews"
                                  },
                                  "placeId": {
                                    "type": "string"
                                  },
                                  "businessName": {
                                    "type": "string"
                                  }
                                },
                                "required": ["channel"],
                                "additionalProperties": false
                              }
                            ]
                          },
                          "aiAgentId": {
                            "anyOf": [
                              {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "aiSettings": {
                            "default": {
                              "enabled": true
                            },
                            "type": "object",
                            "properties": {
                              "enabled": {
                                "default": true,
                                "type": "boolean"
                              },
                              "model": {
                                "type": "string"
                              },
                              "temperature": {
                                "type": "number",
                                "minimum": 0,
                                "maximum": 2
                              },
                              "maxTokens": {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991
                              },
                              "systemPromptOverride": {
                                "type": "string"
                              },
                              "greeting": {
                                "type": "string"
                              },
                              "tone": {
                                "type": "string",
                                "enum": ["professional", "friendly", "casual", "formal"]
                              },
                              "language": {
                                "type": "string"
                              },
                              "additionalInstructions": {
                                "type": "string"
                              },
                              "businessHours": {
                                "type": "object",
                                "properties": {
                                  "timezone": {
                                    "type": "string"
                                  },
                                  "schedule": {
                                    "type": "object",
                                    "properties": {
                                      "monday": {
                                        "type": "object",
                                        "properties": {
                                          "start": {
                                            "type": "string"
                                          },
                                          "end": {
                                            "type": "string"
                                          },
                                          "enabled": {
                                            "type": "boolean"
                                          }
                                        },
                                        "required": ["start", "end", "enabled"],
                                        "additionalProperties": false
                                      },
                                      "tuesday": {
                                        "type": "object",
                                        "properties": {
                                          "start": {
                                            "type": "string"
                                          },
                                          "end": {
                                            "type": "string"
                                          },
                                          "enabled": {
                                            "type": "boolean"
                                          }
                                        },
                                        "required": ["start", "end", "enabled"],
                                        "additionalProperties": false
                                      },
                                      "wednesday": {
                                        "type": "object",
                                        "properties": {
                                          "start": {
                                            "type": "string"
                                          },
                                          "end": {
                                            "type": "string"
                                          },
                                          "enabled": {
                                            "type": "boolean"
                                          }
                                        },
                                        "required": ["start", "end", "enabled"],
                                        "additionalProperties": false
                                      },
                                      "thursday": {
                                        "type": "object",
                                        "properties": {
                                          "start": {
                                            "type": "string"
                                          },
                                          "end": {
                                            "type": "string"
                                          },
                                          "enabled": {
                                            "type": "boolean"
                                          }
                                        },
                                        "required": ["start", "end", "enabled"],
                                        "additionalProperties": false
                                      },
                                      "friday": {
                                        "type": "object",
                                        "properties": {
                                          "start": {
                                            "type": "string"
                                          },
                                          "end": {
                                            "type": "string"
                                          },
                                          "enabled": {
                                            "type": "boolean"
                                          }
                                        },
                                        "required": ["start", "end", "enabled"],
                                        "additionalProperties": false
                                      },
                                      "saturday": {
                                        "type": "object",
                                        "properties": {
                                          "start": {
                                            "type": "string"
                                          },
                                          "end": {
                                            "type": "string"
                                          },
                                          "enabled": {
                                            "type": "boolean"
                                          }
                                        },
                                        "required": ["start", "end", "enabled"],
                                        "additionalProperties": false
                                      },
                                      "sunday": {
                                        "type": "object",
                                        "properties": {
                                          "start": {
                                            "type": "string"
                                          },
                                          "end": {
                                            "type": "string"
                                          },
                                          "enabled": {
                                            "type": "boolean"
                                          }
                                        },
                                        "required": ["start", "end", "enabled"],
                                        "additionalProperties": false
                                      }
                                    },
                                    "additionalProperties": false
                                  }
                                },
                                "required": ["timezone", "schedule"],
                                "additionalProperties": false
                              },
                              "offHoursMessage": {
                                "type": "string"
                              },
                              "maxAiTurns": {
                                "type": "number",
                                "minimum": 1,
                                "maximum": 50
                              },
                              "allowFileUploads": {
                                "type": "boolean"
                              },
                              "toolOverrides": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "skillId": {
                                      "type": "string"
                                    },
                                    "enabled": {
                                      "type": "boolean"
                                    }
                                  },
                                  "required": ["skillId", "enabled"],
                                  "additionalProperties": false
                                }
                              },
                              "emailDecision": {
                                "type": "object",
                                "properties": {
                                  "replyMode": {
                                    "default": "draft",
                                    "type": "string",
                                    "enum": ["draft", "auto"]
                                  },
                                  "decisionPrompt": {
                                    "type": "string"
                                  },
                                  "autoReplyMinConfidence": {
                                    "default": 0.7,
                                    "type": "number",
                                    "minimum": 0,
                                    "maximum": 1
                                  },
                                  "firstTimeSenderMode": {
                                    "default": "draft",
                                    "type": "string",
                                    "enum": ["draft", "auto", "ignore"]
                                  }
                                },
                                "required": [
                                  "replyMode",
                                  "autoReplyMinConfidence",
                                  "firstTimeSenderMode"
                                ],
                                "additionalProperties": false
                              }
                            },
                            "required": ["enabled"],
                            "additionalProperties": false
                          },
                          "autoResolveOverride": {
                            "anyOf": [
                              {
                                "anyOf": [
                                  {
                                    "anyOf": [
                                      {
                                        "type": "string"
                                      },
                                      {
                                        "type": "number"
                                      },
                                      {
                                        "type": "boolean"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  {
                                    "type": "object",
                                    "propertyNames": {
                                      "type": "string"
                                    },
                                    "additionalProperties": {}
                                  },
                                  {
                                    "type": "array",
                                    "items": {}
                                  }
                                ]
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "defaultAssignee": {
                            "type": "string",
                            "enum": ["ai", "agent", "unassigned"]
                          },
                          "defaultAssigneeId": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "createdAt": {
                            "type": "string"
                          },
                          "updatedAt": {
                            "type": "string"
                          },
                          "deletedAt": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        },
                        "required": [
                          "id",
                          "orgId",
                          "name",
                          "channel",
                          "status",
                          "channelConfig",
                          "aiAgentId",
                          "aiSettings",
                          "autoResolveOverride",
                          "defaultAssignee",
                          "defaultAssigneeId",
                          "createdAt",
                          "updatedAt",
                          "deletedAt"
                        ],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": ["inboxes"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "inboxes-create",
        "summary": "Create a new inbox",
        "tags": ["Inboxes"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100
                  },
                  "channel": {
                    "type": "string",
                    "enum": [
                      "voice",
                      "sms",
                      "whatsapp",
                      "chat",
                      "email",
                      "instagram",
                      "google_reviews"
                    ]
                  },
                  "channelConfig": {
                    "oneOf": [
                      {
                        "type": "object",
                        "properties": {
                          "channel": {
                            "type": "string",
                            "const": "voice"
                          },
                          "phoneNumber": {
                            "type": "string"
                          },
                          "twilioPhoneNumberSid": {
                            "type": "string"
                          },
                          "elevenlabsAgentId": {
                            "type": "string"
                          },
                          "maxConcurrentCalls": {
                            "default": 5,
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991
                          },
                          "recordCalls": {
                            "default": false,
                            "type": "boolean"
                          }
                        },
                        "required": ["channel", "phoneNumber", "twilioPhoneNumberSid"]
                      },
                      {
                        "type": "object",
                        "properties": {
                          "channel": {
                            "type": "string",
                            "const": "sms"
                          },
                          "phoneNumber": {
                            "type": "string"
                          },
                          "twilioPhoneNumberSid": {
                            "type": "string"
                          }
                        },
                        "required": ["channel", "phoneNumber", "twilioPhoneNumberSid"]
                      },
                      {
                        "type": "object",
                        "properties": {
                          "channel": {
                            "type": "string",
                            "const": "whatsapp"
                          },
                          "metaPhoneNumberId": {
                            "type": "string"
                          },
                          "phoneNumber": {
                            "type": "string"
                          },
                          "phoneNumberDisplayName": {
                            "type": "string"
                          },
                          "whatsappBusinessAccountId": {
                            "type": "string"
                          },
                          "facebookPageId": {
                            "type": "string"
                          }
                        },
                        "required": ["channel", "metaPhoneNumberId", "phoneNumber"]
                      },
                      {
                        "type": "object",
                        "properties": {
                          "channel": {
                            "type": "string",
                            "const": "chat"
                          },
                          "widgetId": {
                            "type": "string"
                          },
                          "allowedOrigins": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "theme": {
                            "type": "object",
                            "properties": {
                              "primaryColor": {
                                "type": "string"
                              },
                              "position": {
                                "type": "string",
                                "enum": ["bottom-right", "bottom-left"]
                              },
                              "template": {
                                "type": "string"
                              },
                              "backgroundColor": {
                                "type": "string"
                              },
                              "textColor": {
                                "type": "string"
                              },
                              "userBubbleColor": {
                                "type": "string"
                              },
                              "userBubbleTextColor": {
                                "type": "string"
                              },
                              "fontFamily": {
                                "type": "string"
                              },
                              "fontSize": {
                                "type": "string",
                                "enum": ["sm", "base", "lg"]
                              },
                              "messageStyle": {
                                "type": "string",
                                "enum": ["plain", "bubble"]
                              },
                              "logoUrl": {
                                "type": "string"
                              },
                              "headerTitle": {
                                "type": "string"
                              },
                              "poweredBy": {
                                "type": "boolean"
                              }
                            }
                          },
                          "identityVerification": {
                            "type": "object",
                            "properties": {
                              "secret": {
                                "type": "string",
                                "minLength": 16
                              }
                            },
                            "required": ["secret"]
                          },
                          "privacyPolicyUrl": {
                            "type": "string",
                            "maxLength": 2048,
                            "format": "uri"
                          }
                        },
                        "required": ["channel"]
                      },
                      {
                        "type": "object",
                        "properties": {
                          "channel": {
                            "type": "string",
                            "const": "email"
                          },
                          "provider": {
                            "default": "smtp",
                            "type": "string",
                            "enum": ["smtp", "gmail", "microsoft"]
                          },
                          "emailAddress": {
                            "type": "string",
                            "format": "email",
                            "pattern": "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
                          },
                          "inboundAddress": {
                            "type": "string",
                            "format": "email",
                            "pattern": "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
                          },
                          "fromName": {
                            "type": "string"
                          },
                          "replyTo": {
                            "type": "string",
                            "format": "email",
                            "pattern": "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
                          },
                          "sendingDomain": {
                            "type": "string"
                          },
                          "dns": {
                            "type": "object",
                            "properties": {
                              "spf": {
                                "default": "pending",
                                "type": "string",
                                "enum": ["pending", "verified", "failing"]
                              },
                              "dkim": {
                                "default": "pending",
                                "type": "string",
                                "enum": ["pending", "verified", "failing"]
                              },
                              "dmarc": {
                                "default": "pending",
                                "type": "string",
                                "enum": ["pending", "verified", "failing"]
                              }
                            }
                          },
                          "credentialId": {
                            "type": "string"
                          },
                          "syncedLabelIds": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "syncedFolderIds": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          }
                        },
                        "required": ["channel", "emailAddress"]
                      },
                      {
                        "type": "object",
                        "properties": {
                          "channel": {
                            "type": "string",
                            "const": "instagram"
                          },
                          "instagramBusinessAccountId": {
                            "type": "string"
                          },
                          "instagramPageId": {
                            "type": "string"
                          },
                          "instagramUsername": {
                            "type": "string"
                          }
                        },
                        "required": ["channel", "instagramBusinessAccountId", "instagramPageId"]
                      },
                      {
                        "type": "object",
                        "properties": {
                          "channel": {
                            "type": "string",
                            "const": "google_reviews"
                          },
                          "placeId": {
                            "type": "string"
                          },
                          "businessName": {
                            "type": "string"
                          }
                        },
                        "required": ["channel"]
                      }
                    ],
                    "type": "object"
                  },
                  "aiSettings": {
                    "type": "object",
                    "properties": {
                      "enabled": {
                        "default": true,
                        "type": "boolean"
                      },
                      "model": {
                        "type": "string"
                      },
                      "temperature": {
                        "type": "number",
                        "minimum": 0,
                        "maximum": 2
                      },
                      "maxTokens": {
                        "type": "integer",
                        "minimum": -9007199254740991,
                        "maximum": 9007199254740991
                      },
                      "systemPromptOverride": {
                        "type": "string"
                      },
                      "greeting": {
                        "type": "string"
                      },
                      "tone": {
                        "type": "string",
                        "enum": ["professional", "friendly", "casual", "formal"]
                      },
                      "language": {
                        "type": "string"
                      },
                      "additionalInstructions": {
                        "type": "string"
                      },
                      "businessHours": {
                        "type": "object",
                        "properties": {
                          "timezone": {
                            "type": "string"
                          },
                          "schedule": {
                            "type": "object",
                            "properties": {
                              "monday": {
                                "type": "object",
                                "properties": {
                                  "start": {
                                    "type": "string"
                                  },
                                  "end": {
                                    "type": "string"
                                  },
                                  "enabled": {
                                    "type": "boolean"
                                  }
                                },
                                "required": ["start", "end", "enabled"]
                              },
                              "tuesday": {
                                "type": "object",
                                "properties": {
                                  "start": {
                                    "type": "string"
                                  },
                                  "end": {
                                    "type": "string"
                                  },
                                  "enabled": {
                                    "type": "boolean"
                                  }
                                },
                                "required": ["start", "end", "enabled"]
                              },
                              "wednesday": {
                                "type": "object",
                                "properties": {
                                  "start": {
                                    "type": "string"
                                  },
                                  "end": {
                                    "type": "string"
                                  },
                                  "enabled": {
                                    "type": "boolean"
                                  }
                                },
                                "required": ["start", "end", "enabled"]
                              },
                              "thursday": {
                                "type": "object",
                                "properties": {
                                  "start": {
                                    "type": "string"
                                  },
                                  "end": {
                                    "type": "string"
                                  },
                                  "enabled": {
                                    "type": "boolean"
                                  }
                                },
                                "required": ["start", "end", "enabled"]
                              },
                              "friday": {
                                "type": "object",
                                "properties": {
                                  "start": {
                                    "type": "string"
                                  },
                                  "end": {
                                    "type": "string"
                                  },
                                  "enabled": {
                                    "type": "boolean"
                                  }
                                },
                                "required": ["start", "end", "enabled"]
                              },
                              "saturday": {
                                "type": "object",
                                "properties": {
                                  "start": {
                                    "type": "string"
                                  },
                                  "end": {
                                    "type": "string"
                                  },
                                  "enabled": {
                                    "type": "boolean"
                                  }
                                },
                                "required": ["start", "end", "enabled"]
                              },
                              "sunday": {
                                "type": "object",
                                "properties": {
                                  "start": {
                                    "type": "string"
                                  },
                                  "end": {
                                    "type": "string"
                                  },
                                  "enabled": {
                                    "type": "boolean"
                                  }
                                },
                                "required": ["start", "end", "enabled"]
                              }
                            }
                          }
                        },
                        "required": ["timezone", "schedule"]
                      },
                      "offHoursMessage": {
                        "type": "string"
                      },
                      "maxAiTurns": {
                        "type": "number",
                        "minimum": 1,
                        "maximum": 50
                      },
                      "allowFileUploads": {
                        "type": "boolean"
                      },
                      "toolOverrides": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "skillId": {
                              "type": "string"
                            },
                            "enabled": {
                              "type": "boolean"
                            }
                          },
                          "required": ["skillId", "enabled"]
                        }
                      },
                      "emailDecision": {
                        "type": "object",
                        "properties": {
                          "replyMode": {
                            "default": "draft",
                            "type": "string",
                            "enum": ["draft", "auto"]
                          },
                          "decisionPrompt": {
                            "type": "string"
                          },
                          "autoReplyMinConfidence": {
                            "default": 0.7,
                            "type": "number",
                            "minimum": 0,
                            "maximum": 1
                          },
                          "firstTimeSenderMode": {
                            "default": "draft",
                            "type": "string",
                            "enum": ["draft", "auto", "ignore"]
                          }
                        }
                      }
                    }
                  },
                  "defaultAssignee": {
                    "type": "string",
                    "enum": ["ai", "agent", "unassigned"]
                  },
                  "defaultAssigneeId": {
                    "type": "string"
                  },
                  "aiAgentId": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                },
                "required": ["orgId", "name", "channel", "channelConfig"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "orgId": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "channel": {
                      "type": "string",
                      "enum": [
                        "voice",
                        "sms",
                        "whatsapp",
                        "chat",
                        "email",
                        "instagram",
                        "google_reviews"
                      ]
                    },
                    "status": {
                      "type": "string",
                      "enum": ["active", "paused", "disabled"]
                    },
                    "channelConfig": {
                      "default": {},
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "channel": {
                              "type": "string",
                              "const": "voice"
                            },
                            "phoneNumber": {
                              "type": "string"
                            },
                            "twilioPhoneNumberSid": {
                              "type": "string"
                            },
                            "elevenlabsAgentId": {
                              "type": "string"
                            },
                            "maxConcurrentCalls": {
                              "default": 5,
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991
                            },
                            "recordCalls": {
                              "default": false,
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "channel",
                            "phoneNumber",
                            "twilioPhoneNumberSid",
                            "maxConcurrentCalls",
                            "recordCalls"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "channel": {
                              "type": "string",
                              "const": "sms"
                            },
                            "phoneNumber": {
                              "type": "string"
                            },
                            "twilioPhoneNumberSid": {
                              "type": "string"
                            }
                          },
                          "required": ["channel", "phoneNumber", "twilioPhoneNumberSid"],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "channel": {
                              "type": "string",
                              "const": "whatsapp"
                            },
                            "metaPhoneNumberId": {
                              "type": "string"
                            },
                            "phoneNumber": {
                              "type": "string"
                            },
                            "phoneNumberDisplayName": {
                              "type": "string"
                            },
                            "whatsappBusinessAccountId": {
                              "type": "string"
                            },
                            "facebookPageId": {
                              "type": "string"
                            }
                          },
                          "required": ["channel", "metaPhoneNumberId", "phoneNumber"],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "channel": {
                              "type": "string",
                              "const": "chat"
                            },
                            "widgetId": {
                              "type": "string"
                            },
                            "allowedOrigins": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "theme": {
                              "type": "object",
                              "properties": {
                                "primaryColor": {
                                  "type": "string"
                                },
                                "position": {
                                  "type": "string",
                                  "enum": ["bottom-right", "bottom-left"]
                                },
                                "template": {
                                  "type": "string"
                                },
                                "backgroundColor": {
                                  "type": "string"
                                },
                                "textColor": {
                                  "type": "string"
                                },
                                "userBubbleColor": {
                                  "type": "string"
                                },
                                "userBubbleTextColor": {
                                  "type": "string"
                                },
                                "fontFamily": {
                                  "type": "string"
                                },
                                "fontSize": {
                                  "type": "string",
                                  "enum": ["sm", "base", "lg"]
                                },
                                "messageStyle": {
                                  "type": "string",
                                  "enum": ["plain", "bubble"]
                                },
                                "logoUrl": {
                                  "type": "string"
                                },
                                "headerTitle": {
                                  "type": "string"
                                },
                                "poweredBy": {
                                  "type": "boolean"
                                }
                              },
                              "additionalProperties": false
                            },
                            "privacyPolicyUrl": {
                              "type": "string",
                              "maxLength": 2048,
                              "format": "uri"
                            },
                            "identityVerificationConfigured": {
                              "type": "boolean"
                            }
                          },
                          "required": ["channel"],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "channel": {
                              "type": "string",
                              "const": "email"
                            },
                            "provider": {
                              "default": "smtp",
                              "type": "string",
                              "enum": ["smtp", "gmail", "microsoft"]
                            },
                            "emailAddress": {
                              "type": "string",
                              "format": "email",
                              "pattern": "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
                            },
                            "inboundAddress": {
                              "type": "string",
                              "format": "email",
                              "pattern": "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
                            },
                            "fromName": {
                              "type": "string"
                            },
                            "replyTo": {
                              "type": "string",
                              "format": "email",
                              "pattern": "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
                            },
                            "sendingDomain": {
                              "type": "string"
                            },
                            "dns": {
                              "type": "object",
                              "properties": {
                                "spf": {
                                  "default": "pending",
                                  "type": "string",
                                  "enum": ["pending", "verified", "failing"]
                                },
                                "dkim": {
                                  "default": "pending",
                                  "type": "string",
                                  "enum": ["pending", "verified", "failing"]
                                },
                                "dmarc": {
                                  "default": "pending",
                                  "type": "string",
                                  "enum": ["pending", "verified", "failing"]
                                }
                              },
                              "required": ["spf", "dkim", "dmarc"],
                              "additionalProperties": false
                            },
                            "credentialId": {
                              "type": "string"
                            },
                            "syncedLabelIds": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "syncedFolderIds": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            }
                          },
                          "required": ["channel", "provider", "emailAddress"],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "channel": {
                              "type": "string",
                              "const": "instagram"
                            },
                            "instagramBusinessAccountId": {
                              "type": "string"
                            },
                            "instagramPageId": {
                              "type": "string"
                            },
                            "instagramUsername": {
                              "type": "string"
                            }
                          },
                          "required": ["channel", "instagramBusinessAccountId", "instagramPageId"],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "channel": {
                              "type": "string",
                              "const": "google_reviews"
                            },
                            "placeId": {
                              "type": "string"
                            },
                            "businessName": {
                              "type": "string"
                            }
                          },
                          "required": ["channel"],
                          "additionalProperties": false
                        }
                      ]
                    },
                    "aiAgentId": {
                      "anyOf": [
                        {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "aiSettings": {
                      "default": {
                        "enabled": true
                      },
                      "type": "object",
                      "properties": {
                        "enabled": {
                          "default": true,
                          "type": "boolean"
                        },
                        "model": {
                          "type": "string"
                        },
                        "temperature": {
                          "type": "number",
                          "minimum": 0,
                          "maximum": 2
                        },
                        "maxTokens": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "systemPromptOverride": {
                          "type": "string"
                        },
                        "greeting": {
                          "type": "string"
                        },
                        "tone": {
                          "type": "string",
                          "enum": ["professional", "friendly", "casual", "formal"]
                        },
                        "language": {
                          "type": "string"
                        },
                        "additionalInstructions": {
                          "type": "string"
                        },
                        "businessHours": {
                          "type": "object",
                          "properties": {
                            "timezone": {
                              "type": "string"
                            },
                            "schedule": {
                              "type": "object",
                              "properties": {
                                "monday": {
                                  "type": "object",
                                  "properties": {
                                    "start": {
                                      "type": "string"
                                    },
                                    "end": {
                                      "type": "string"
                                    },
                                    "enabled": {
                                      "type": "boolean"
                                    }
                                  },
                                  "required": ["start", "end", "enabled"],
                                  "additionalProperties": false
                                },
                                "tuesday": {
                                  "type": "object",
                                  "properties": {
                                    "start": {
                                      "type": "string"
                                    },
                                    "end": {
                                      "type": "string"
                                    },
                                    "enabled": {
                                      "type": "boolean"
                                    }
                                  },
                                  "required": ["start", "end", "enabled"],
                                  "additionalProperties": false
                                },
                                "wednesday": {
                                  "type": "object",
                                  "properties": {
                                    "start": {
                                      "type": "string"
                                    },
                                    "end": {
                                      "type": "string"
                                    },
                                    "enabled": {
                                      "type": "boolean"
                                    }
                                  },
                                  "required": ["start", "end", "enabled"],
                                  "additionalProperties": false
                                },
                                "thursday": {
                                  "type": "object",
                                  "properties": {
                                    "start": {
                                      "type": "string"
                                    },
                                    "end": {
                                      "type": "string"
                                    },
                                    "enabled": {
                                      "type": "boolean"
                                    }
                                  },
                                  "required": ["start", "end", "enabled"],
                                  "additionalProperties": false
                                },
                                "friday": {
                                  "type": "object",
                                  "properties": {
                                    "start": {
                                      "type": "string"
                                    },
                                    "end": {
                                      "type": "string"
                                    },
                                    "enabled": {
                                      "type": "boolean"
                                    }
                                  },
                                  "required": ["start", "end", "enabled"],
                                  "additionalProperties": false
                                },
                                "saturday": {
                                  "type": "object",
                                  "properties": {
                                    "start": {
                                      "type": "string"
                                    },
                                    "end": {
                                      "type": "string"
                                    },
                                    "enabled": {
                                      "type": "boolean"
                                    }
                                  },
                                  "required": ["start", "end", "enabled"],
                                  "additionalProperties": false
                                },
                                "sunday": {
                                  "type": "object",
                                  "properties": {
                                    "start": {
                                      "type": "string"
                                    },
                                    "end": {
                                      "type": "string"
                                    },
                                    "enabled": {
                                      "type": "boolean"
                                    }
                                  },
                                  "required": ["start", "end", "enabled"],
                                  "additionalProperties": false
                                }
                              },
                              "additionalProperties": false
                            }
                          },
                          "required": ["timezone", "schedule"],
                          "additionalProperties": false
                        },
                        "offHoursMessage": {
                          "type": "string"
                        },
                        "maxAiTurns": {
                          "type": "number",
                          "minimum": 1,
                          "maximum": 50
                        },
                        "allowFileUploads": {
                          "type": "boolean"
                        },
                        "toolOverrides": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "skillId": {
                                "type": "string"
                              },
                              "enabled": {
                                "type": "boolean"
                              }
                            },
                            "required": ["skillId", "enabled"],
                            "additionalProperties": false
                          }
                        },
                        "emailDecision": {
                          "type": "object",
                          "properties": {
                            "replyMode": {
                              "default": "draft",
                              "type": "string",
                              "enum": ["draft", "auto"]
                            },
                            "decisionPrompt": {
                              "type": "string"
                            },
                            "autoReplyMinConfidence": {
                              "default": 0.7,
                              "type": "number",
                              "minimum": 0,
                              "maximum": 1
                            },
                            "firstTimeSenderMode": {
                              "default": "draft",
                              "type": "string",
                              "enum": ["draft", "auto", "ignore"]
                            }
                          },
                          "required": [
                            "replyMode",
                            "autoReplyMinConfidence",
                            "firstTimeSenderMode"
                          ],
                          "additionalProperties": false
                        }
                      },
                      "required": ["enabled"],
                      "additionalProperties": false
                    },
                    "autoResolveOverride": {
                      "anyOf": [
                        {
                          "anyOf": [
                            {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "number"
                                },
                                {
                                  "type": "boolean"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            {
                              "type": "object",
                              "propertyNames": {
                                "type": "string"
                              },
                              "additionalProperties": {}
                            },
                            {
                              "type": "array",
                              "items": {}
                            }
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "defaultAssignee": {
                      "type": "string",
                      "enum": ["ai", "agent", "unassigned"]
                    },
                    "defaultAssigneeId": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "createdAt": {
                      "type": "string"
                    },
                    "updatedAt": {
                      "type": "string"
                    },
                    "deletedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": [
                    "id",
                    "orgId",
                    "name",
                    "channel",
                    "status",
                    "channelConfig",
                    "aiAgentId",
                    "aiSettings",
                    "autoResolveOverride",
                    "defaultAssignee",
                    "defaultAssigneeId",
                    "createdAt",
                    "updatedAt",
                    "deletedAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/inboxes/{id}": {
      "get": {
        "operationId": "inboxes-get",
        "summary": "Get inbox by ID",
        "tags": ["Inboxes"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "orgId": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "channel": {
                      "type": "string",
                      "enum": [
                        "voice",
                        "sms",
                        "whatsapp",
                        "chat",
                        "email",
                        "instagram",
                        "google_reviews"
                      ]
                    },
                    "status": {
                      "type": "string",
                      "enum": ["active", "paused", "disabled"]
                    },
                    "channelConfig": {
                      "default": {},
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "channel": {
                              "type": "string",
                              "const": "voice"
                            },
                            "phoneNumber": {
                              "type": "string"
                            },
                            "twilioPhoneNumberSid": {
                              "type": "string"
                            },
                            "elevenlabsAgentId": {
                              "type": "string"
                            },
                            "maxConcurrentCalls": {
                              "default": 5,
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991
                            },
                            "recordCalls": {
                              "default": false,
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "channel",
                            "phoneNumber",
                            "twilioPhoneNumberSid",
                            "maxConcurrentCalls",
                            "recordCalls"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "channel": {
                              "type": "string",
                              "const": "sms"
                            },
                            "phoneNumber": {
                              "type": "string"
                            },
                            "twilioPhoneNumberSid": {
                              "type": "string"
                            }
                          },
                          "required": ["channel", "phoneNumber", "twilioPhoneNumberSid"],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "channel": {
                              "type": "string",
                              "const": "whatsapp"
                            },
                            "metaPhoneNumberId": {
                              "type": "string"
                            },
                            "phoneNumber": {
                              "type": "string"
                            },
                            "phoneNumberDisplayName": {
                              "type": "string"
                            },
                            "whatsappBusinessAccountId": {
                              "type": "string"
                            },
                            "facebookPageId": {
                              "type": "string"
                            }
                          },
                          "required": ["channel", "metaPhoneNumberId", "phoneNumber"],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "channel": {
                              "type": "string",
                              "const": "chat"
                            },
                            "widgetId": {
                              "type": "string"
                            },
                            "allowedOrigins": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "theme": {
                              "type": "object",
                              "properties": {
                                "primaryColor": {
                                  "type": "string"
                                },
                                "position": {
                                  "type": "string",
                                  "enum": ["bottom-right", "bottom-left"]
                                },
                                "template": {
                                  "type": "string"
                                },
                                "backgroundColor": {
                                  "type": "string"
                                },
                                "textColor": {
                                  "type": "string"
                                },
                                "userBubbleColor": {
                                  "type": "string"
                                },
                                "userBubbleTextColor": {
                                  "type": "string"
                                },
                                "fontFamily": {
                                  "type": "string"
                                },
                                "fontSize": {
                                  "type": "string",
                                  "enum": ["sm", "base", "lg"]
                                },
                                "messageStyle": {
                                  "type": "string",
                                  "enum": ["plain", "bubble"]
                                },
                                "logoUrl": {
                                  "type": "string"
                                },
                                "headerTitle": {
                                  "type": "string"
                                },
                                "poweredBy": {
                                  "type": "boolean"
                                }
                              },
                              "additionalProperties": false
                            },
                            "privacyPolicyUrl": {
                              "type": "string",
                              "maxLength": 2048,
                              "format": "uri"
                            },
                            "identityVerificationConfigured": {
                              "type": "boolean"
                            }
                          },
                          "required": ["channel"],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "channel": {
                              "type": "string",
                              "const": "email"
                            },
                            "provider": {
                              "default": "smtp",
                              "type": "string",
                              "enum": ["smtp", "gmail", "microsoft"]
                            },
                            "emailAddress": {
                              "type": "string",
                              "format": "email",
                              "pattern": "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
                            },
                            "inboundAddress": {
                              "type": "string",
                              "format": "email",
                              "pattern": "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
                            },
                            "fromName": {
                              "type": "string"
                            },
                            "replyTo": {
                              "type": "string",
                              "format": "email",
                              "pattern": "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
                            },
                            "sendingDomain": {
                              "type": "string"
                            },
                            "dns": {
                              "type": "object",
                              "properties": {
                                "spf": {
                                  "default": "pending",
                                  "type": "string",
                                  "enum": ["pending", "verified", "failing"]
                                },
                                "dkim": {
                                  "default": "pending",
                                  "type": "string",
                                  "enum": ["pending", "verified", "failing"]
                                },
                                "dmarc": {
                                  "default": "pending",
                                  "type": "string",
                                  "enum": ["pending", "verified", "failing"]
                                }
                              },
                              "required": ["spf", "dkim", "dmarc"],
                              "additionalProperties": false
                            },
                            "credentialId": {
                              "type": "string"
                            },
                            "syncedLabelIds": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "syncedFolderIds": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            }
                          },
                          "required": ["channel", "provider", "emailAddress"],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "channel": {
                              "type": "string",
                              "const": "instagram"
                            },
                            "instagramBusinessAccountId": {
                              "type": "string"
                            },
                            "instagramPageId": {
                              "type": "string"
                            },
                            "instagramUsername": {
                              "type": "string"
                            }
                          },
                          "required": ["channel", "instagramBusinessAccountId", "instagramPageId"],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "channel": {
                              "type": "string",
                              "const": "google_reviews"
                            },
                            "placeId": {
                              "type": "string"
                            },
                            "businessName": {
                              "type": "string"
                            }
                          },
                          "required": ["channel"],
                          "additionalProperties": false
                        }
                      ]
                    },
                    "aiAgentId": {
                      "anyOf": [
                        {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "aiSettings": {
                      "default": {
                        "enabled": true
                      },
                      "type": "object",
                      "properties": {
                        "enabled": {
                          "default": true,
                          "type": "boolean"
                        },
                        "model": {
                          "type": "string"
                        },
                        "temperature": {
                          "type": "number",
                          "minimum": 0,
                          "maximum": 2
                        },
                        "maxTokens": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "systemPromptOverride": {
                          "type": "string"
                        },
                        "greeting": {
                          "type": "string"
                        },
                        "tone": {
                          "type": "string",
                          "enum": ["professional", "friendly", "casual", "formal"]
                        },
                        "language": {
                          "type": "string"
                        },
                        "additionalInstructions": {
                          "type": "string"
                        },
                        "businessHours": {
                          "type": "object",
                          "properties": {
                            "timezone": {
                              "type": "string"
                            },
                            "schedule": {
                              "type": "object",
                              "properties": {
                                "monday": {
                                  "type": "object",
                                  "properties": {
                                    "start": {
                                      "type": "string"
                                    },
                                    "end": {
                                      "type": "string"
                                    },
                                    "enabled": {
                                      "type": "boolean"
                                    }
                                  },
                                  "required": ["start", "end", "enabled"],
                                  "additionalProperties": false
                                },
                                "tuesday": {
                                  "type": "object",
                                  "properties": {
                                    "start": {
                                      "type": "string"
                                    },
                                    "end": {
                                      "type": "string"
                                    },
                                    "enabled": {
                                      "type": "boolean"
                                    }
                                  },
                                  "required": ["start", "end", "enabled"],
                                  "additionalProperties": false
                                },
                                "wednesday": {
                                  "type": "object",
                                  "properties": {
                                    "start": {
                                      "type": "string"
                                    },
                                    "end": {
                                      "type": "string"
                                    },
                                    "enabled": {
                                      "type": "boolean"
                                    }
                                  },
                                  "required": ["start", "end", "enabled"],
                                  "additionalProperties": false
                                },
                                "thursday": {
                                  "type": "object",
                                  "properties": {
                                    "start": {
                                      "type": "string"
                                    },
                                    "end": {
                                      "type": "string"
                                    },
                                    "enabled": {
                                      "type": "boolean"
                                    }
                                  },
                                  "required": ["start", "end", "enabled"],
                                  "additionalProperties": false
                                },
                                "friday": {
                                  "type": "object",
                                  "properties": {
                                    "start": {
                                      "type": "string"
                                    },
                                    "end": {
                                      "type": "string"
                                    },
                                    "enabled": {
                                      "type": "boolean"
                                    }
                                  },
                                  "required": ["start", "end", "enabled"],
                                  "additionalProperties": false
                                },
                                "saturday": {
                                  "type": "object",
                                  "properties": {
                                    "start": {
                                      "type": "string"
                                    },
                                    "end": {
                                      "type": "string"
                                    },
                                    "enabled": {
                                      "type": "boolean"
                                    }
                                  },
                                  "required": ["start", "end", "enabled"],
                                  "additionalProperties": false
                                },
                                "sunday": {
                                  "type": "object",
                                  "properties": {
                                    "start": {
                                      "type": "string"
                                    },
                                    "end": {
                                      "type": "string"
                                    },
                                    "enabled": {
                                      "type": "boolean"
                                    }
                                  },
                                  "required": ["start", "end", "enabled"],
                                  "additionalProperties": false
                                }
                              },
                              "additionalProperties": false
                            }
                          },
                          "required": ["timezone", "schedule"],
                          "additionalProperties": false
                        },
                        "offHoursMessage": {
                          "type": "string"
                        },
                        "maxAiTurns": {
                          "type": "number",
                          "minimum": 1,
                          "maximum": 50
                        },
                        "allowFileUploads": {
                          "type": "boolean"
                        },
                        "toolOverrides": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "skillId": {
                                "type": "string"
                              },
                              "enabled": {
                                "type": "boolean"
                              }
                            },
                            "required": ["skillId", "enabled"],
                            "additionalProperties": false
                          }
                        },
                        "emailDecision": {
                          "type": "object",
                          "properties": {
                            "replyMode": {
                              "default": "draft",
                              "type": "string",
                              "enum": ["draft", "auto"]
                            },
                            "decisionPrompt": {
                              "type": "string"
                            },
                            "autoReplyMinConfidence": {
                              "default": 0.7,
                              "type": "number",
                              "minimum": 0,
                              "maximum": 1
                            },
                            "firstTimeSenderMode": {
                              "default": "draft",
                              "type": "string",
                              "enum": ["draft", "auto", "ignore"]
                            }
                          },
                          "required": [
                            "replyMode",
                            "autoReplyMinConfidence",
                            "firstTimeSenderMode"
                          ],
                          "additionalProperties": false
                        }
                      },
                      "required": ["enabled"],
                      "additionalProperties": false
                    },
                    "autoResolveOverride": {
                      "anyOf": [
                        {
                          "anyOf": [
                            {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "number"
                                },
                                {
                                  "type": "boolean"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            {
                              "type": "object",
                              "propertyNames": {
                                "type": "string"
                              },
                              "additionalProperties": {}
                            },
                            {
                              "type": "array",
                              "items": {}
                            }
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "defaultAssignee": {
                      "type": "string",
                      "enum": ["ai", "agent", "unassigned"]
                    },
                    "defaultAssigneeId": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "createdAt": {
                      "type": "string"
                    },
                    "updatedAt": {
                      "type": "string"
                    },
                    "deletedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": [
                    "id",
                    "orgId",
                    "name",
                    "channel",
                    "status",
                    "channelConfig",
                    "aiAgentId",
                    "aiSettings",
                    "autoResolveOverride",
                    "defaultAssignee",
                    "defaultAssigneeId",
                    "createdAt",
                    "updatedAt",
                    "deletedAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "inboxes-update",
        "summary": "Update an inbox",
        "tags": ["Inboxes"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100
                  },
                  "status": {
                    "type": "string",
                    "enum": ["active", "paused", "disabled"]
                  },
                  "channelConfig": {
                    "oneOf": [
                      {
                        "type": "object",
                        "properties": {
                          "channel": {
                            "type": "string",
                            "const": "voice"
                          },
                          "phoneNumber": {
                            "type": "string"
                          },
                          "twilioPhoneNumberSid": {
                            "type": "string"
                          },
                          "elevenlabsAgentId": {
                            "type": "string"
                          },
                          "maxConcurrentCalls": {
                            "default": 5,
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991
                          },
                          "recordCalls": {
                            "default": false,
                            "type": "boolean"
                          }
                        },
                        "required": ["channel", "phoneNumber", "twilioPhoneNumberSid"]
                      },
                      {
                        "type": "object",
                        "properties": {
                          "channel": {
                            "type": "string",
                            "const": "sms"
                          },
                          "phoneNumber": {
                            "type": "string"
                          },
                          "twilioPhoneNumberSid": {
                            "type": "string"
                          }
                        },
                        "required": ["channel", "phoneNumber", "twilioPhoneNumberSid"]
                      },
                      {
                        "type": "object",
                        "properties": {
                          "channel": {
                            "type": "string",
                            "const": "whatsapp"
                          },
                          "metaPhoneNumberId": {
                            "type": "string"
                          },
                          "phoneNumber": {
                            "type": "string"
                          },
                          "phoneNumberDisplayName": {
                            "type": "string"
                          },
                          "whatsappBusinessAccountId": {
                            "type": "string"
                          },
                          "facebookPageId": {
                            "type": "string"
                          }
                        },
                        "required": ["channel", "metaPhoneNumberId", "phoneNumber"]
                      },
                      {
                        "type": "object",
                        "properties": {
                          "channel": {
                            "type": "string",
                            "const": "chat"
                          },
                          "widgetId": {
                            "type": "string"
                          },
                          "allowedOrigins": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "theme": {
                            "type": "object",
                            "properties": {
                              "primaryColor": {
                                "type": "string"
                              },
                              "position": {
                                "type": "string",
                                "enum": ["bottom-right", "bottom-left"]
                              },
                              "template": {
                                "type": "string"
                              },
                              "backgroundColor": {
                                "type": "string"
                              },
                              "textColor": {
                                "type": "string"
                              },
                              "userBubbleColor": {
                                "type": "string"
                              },
                              "userBubbleTextColor": {
                                "type": "string"
                              },
                              "fontFamily": {
                                "type": "string"
                              },
                              "fontSize": {
                                "type": "string",
                                "enum": ["sm", "base", "lg"]
                              },
                              "messageStyle": {
                                "type": "string",
                                "enum": ["plain", "bubble"]
                              },
                              "logoUrl": {
                                "type": "string"
                              },
                              "headerTitle": {
                                "type": "string"
                              },
                              "poweredBy": {
                                "type": "boolean"
                              }
                            }
                          },
                          "identityVerification": {
                            "type": "object",
                            "properties": {
                              "secret": {
                                "type": "string",
                                "minLength": 16
                              }
                            },
                            "required": ["secret"]
                          },
                          "privacyPolicyUrl": {
                            "type": "string",
                            "maxLength": 2048,
                            "format": "uri"
                          }
                        },
                        "required": ["channel"]
                      },
                      {
                        "type": "object",
                        "properties": {
                          "channel": {
                            "type": "string",
                            "const": "email"
                          },
                          "provider": {
                            "default": "smtp",
                            "type": "string",
                            "enum": ["smtp", "gmail", "microsoft"]
                          },
                          "emailAddress": {
                            "type": "string",
                            "format": "email",
                            "pattern": "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
                          },
                          "inboundAddress": {
                            "type": "string",
                            "format": "email",
                            "pattern": "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
                          },
                          "fromName": {
                            "type": "string"
                          },
                          "replyTo": {
                            "type": "string",
                            "format": "email",
                            "pattern": "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
                          },
                          "sendingDomain": {
                            "type": "string"
                          },
                          "dns": {
                            "type": "object",
                            "properties": {
                              "spf": {
                                "default": "pending",
                                "type": "string",
                                "enum": ["pending", "verified", "failing"]
                              },
                              "dkim": {
                                "default": "pending",
                                "type": "string",
                                "enum": ["pending", "verified", "failing"]
                              },
                              "dmarc": {
                                "default": "pending",
                                "type": "string",
                                "enum": ["pending", "verified", "failing"]
                              }
                            }
                          },
                          "credentialId": {
                            "type": "string"
                          },
                          "syncedLabelIds": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "syncedFolderIds": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          }
                        },
                        "required": ["channel", "emailAddress"]
                      },
                      {
                        "type": "object",
                        "properties": {
                          "channel": {
                            "type": "string",
                            "const": "instagram"
                          },
                          "instagramBusinessAccountId": {
                            "type": "string"
                          },
                          "instagramPageId": {
                            "type": "string"
                          },
                          "instagramUsername": {
                            "type": "string"
                          }
                        },
                        "required": ["channel", "instagramBusinessAccountId", "instagramPageId"]
                      },
                      {
                        "type": "object",
                        "properties": {
                          "channel": {
                            "type": "string",
                            "const": "google_reviews"
                          },
                          "placeId": {
                            "type": "string"
                          },
                          "businessName": {
                            "type": "string"
                          }
                        },
                        "required": ["channel"]
                      }
                    ],
                    "type": "object"
                  },
                  "aiSettings": {
                    "type": "object",
                    "properties": {
                      "enabled": {
                        "default": true,
                        "type": "boolean"
                      },
                      "model": {
                        "type": "string"
                      },
                      "temperature": {
                        "type": "number",
                        "minimum": 0,
                        "maximum": 2
                      },
                      "maxTokens": {
                        "type": "integer",
                        "minimum": -9007199254740991,
                        "maximum": 9007199254740991
                      },
                      "systemPromptOverride": {
                        "type": "string"
                      },
                      "greeting": {
                        "type": "string"
                      },
                      "tone": {
                        "type": "string",
                        "enum": ["professional", "friendly", "casual", "formal"]
                      },
                      "language": {
                        "type": "string"
                      },
                      "additionalInstructions": {
                        "type": "string"
                      },
                      "businessHours": {
                        "type": "object",
                        "properties": {
                          "timezone": {
                            "type": "string"
                          },
                          "schedule": {
                            "type": "object",
                            "properties": {
                              "monday": {
                                "type": "object",
                                "properties": {
                                  "start": {
                                    "type": "string"
                                  },
                                  "end": {
                                    "type": "string"
                                  },
                                  "enabled": {
                                    "type": "boolean"
                                  }
                                },
                                "required": ["start", "end", "enabled"]
                              },
                              "tuesday": {
                                "type": "object",
                                "properties": {
                                  "start": {
                                    "type": "string"
                                  },
                                  "end": {
                                    "type": "string"
                                  },
                                  "enabled": {
                                    "type": "boolean"
                                  }
                                },
                                "required": ["start", "end", "enabled"]
                              },
                              "wednesday": {
                                "type": "object",
                                "properties": {
                                  "start": {
                                    "type": "string"
                                  },
                                  "end": {
                                    "type": "string"
                                  },
                                  "enabled": {
                                    "type": "boolean"
                                  }
                                },
                                "required": ["start", "end", "enabled"]
                              },
                              "thursday": {
                                "type": "object",
                                "properties": {
                                  "start": {
                                    "type": "string"
                                  },
                                  "end": {
                                    "type": "string"
                                  },
                                  "enabled": {
                                    "type": "boolean"
                                  }
                                },
                                "required": ["start", "end", "enabled"]
                              },
                              "friday": {
                                "type": "object",
                                "properties": {
                                  "start": {
                                    "type": "string"
                                  },
                                  "end": {
                                    "type": "string"
                                  },
                                  "enabled": {
                                    "type": "boolean"
                                  }
                                },
                                "required": ["start", "end", "enabled"]
                              },
                              "saturday": {
                                "type": "object",
                                "properties": {
                                  "start": {
                                    "type": "string"
                                  },
                                  "end": {
                                    "type": "string"
                                  },
                                  "enabled": {
                                    "type": "boolean"
                                  }
                                },
                                "required": ["start", "end", "enabled"]
                              },
                              "sunday": {
                                "type": "object",
                                "properties": {
                                  "start": {
                                    "type": "string"
                                  },
                                  "end": {
                                    "type": "string"
                                  },
                                  "enabled": {
                                    "type": "boolean"
                                  }
                                },
                                "required": ["start", "end", "enabled"]
                              }
                            }
                          }
                        },
                        "required": ["timezone", "schedule"]
                      },
                      "offHoursMessage": {
                        "type": "string"
                      },
                      "maxAiTurns": {
                        "type": "number",
                        "minimum": 1,
                        "maximum": 50
                      },
                      "allowFileUploads": {
                        "type": "boolean"
                      },
                      "toolOverrides": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "skillId": {
                              "type": "string"
                            },
                            "enabled": {
                              "type": "boolean"
                            }
                          },
                          "required": ["skillId", "enabled"]
                        }
                      },
                      "emailDecision": {
                        "type": "object",
                        "properties": {
                          "replyMode": {
                            "default": "draft",
                            "type": "string",
                            "enum": ["draft", "auto"]
                          },
                          "decisionPrompt": {
                            "type": "string"
                          },
                          "autoReplyMinConfidence": {
                            "default": 0.7,
                            "type": "number",
                            "minimum": 0,
                            "maximum": 1
                          },
                          "firstTimeSenderMode": {
                            "default": "draft",
                            "type": "string",
                            "enum": ["draft", "auto", "ignore"]
                          }
                        }
                      }
                    }
                  },
                  "defaultAssignee": {
                    "type": "string",
                    "enum": ["ai", "agent", "unassigned"]
                  },
                  "defaultAssigneeId": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "aiAgentId": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "clearIdentityVerification": {
                    "type": "boolean"
                  }
                },
                "required": ["orgId"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "orgId": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "channel": {
                      "type": "string",
                      "enum": [
                        "voice",
                        "sms",
                        "whatsapp",
                        "chat",
                        "email",
                        "instagram",
                        "google_reviews"
                      ]
                    },
                    "status": {
                      "type": "string",
                      "enum": ["active", "paused", "disabled"]
                    },
                    "channelConfig": {
                      "default": {},
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "channel": {
                              "type": "string",
                              "const": "voice"
                            },
                            "phoneNumber": {
                              "type": "string"
                            },
                            "twilioPhoneNumberSid": {
                              "type": "string"
                            },
                            "elevenlabsAgentId": {
                              "type": "string"
                            },
                            "maxConcurrentCalls": {
                              "default": 5,
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991
                            },
                            "recordCalls": {
                              "default": false,
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "channel",
                            "phoneNumber",
                            "twilioPhoneNumberSid",
                            "maxConcurrentCalls",
                            "recordCalls"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "channel": {
                              "type": "string",
                              "const": "sms"
                            },
                            "phoneNumber": {
                              "type": "string"
                            },
                            "twilioPhoneNumberSid": {
                              "type": "string"
                            }
                          },
                          "required": ["channel", "phoneNumber", "twilioPhoneNumberSid"],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "channel": {
                              "type": "string",
                              "const": "whatsapp"
                            },
                            "metaPhoneNumberId": {
                              "type": "string"
                            },
                            "phoneNumber": {
                              "type": "string"
                            },
                            "phoneNumberDisplayName": {
                              "type": "string"
                            },
                            "whatsappBusinessAccountId": {
                              "type": "string"
                            },
                            "facebookPageId": {
                              "type": "string"
                            }
                          },
                          "required": ["channel", "metaPhoneNumberId", "phoneNumber"],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "channel": {
                              "type": "string",
                              "const": "chat"
                            },
                            "widgetId": {
                              "type": "string"
                            },
                            "allowedOrigins": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "theme": {
                              "type": "object",
                              "properties": {
                                "primaryColor": {
                                  "type": "string"
                                },
                                "position": {
                                  "type": "string",
                                  "enum": ["bottom-right", "bottom-left"]
                                },
                                "template": {
                                  "type": "string"
                                },
                                "backgroundColor": {
                                  "type": "string"
                                },
                                "textColor": {
                                  "type": "string"
                                },
                                "userBubbleColor": {
                                  "type": "string"
                                },
                                "userBubbleTextColor": {
                                  "type": "string"
                                },
                                "fontFamily": {
                                  "type": "string"
                                },
                                "fontSize": {
                                  "type": "string",
                                  "enum": ["sm", "base", "lg"]
                                },
                                "messageStyle": {
                                  "type": "string",
                                  "enum": ["plain", "bubble"]
                                },
                                "logoUrl": {
                                  "type": "string"
                                },
                                "headerTitle": {
                                  "type": "string"
                                },
                                "poweredBy": {
                                  "type": "boolean"
                                }
                              },
                              "additionalProperties": false
                            },
                            "privacyPolicyUrl": {
                              "type": "string",
                              "maxLength": 2048,
                              "format": "uri"
                            },
                            "identityVerificationConfigured": {
                              "type": "boolean"
                            }
                          },
                          "required": ["channel"],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "channel": {
                              "type": "string",
                              "const": "email"
                            },
                            "provider": {
                              "default": "smtp",
                              "type": "string",
                              "enum": ["smtp", "gmail", "microsoft"]
                            },
                            "emailAddress": {
                              "type": "string",
                              "format": "email",
                              "pattern": "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
                            },
                            "inboundAddress": {
                              "type": "string",
                              "format": "email",
                              "pattern": "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
                            },
                            "fromName": {
                              "type": "string"
                            },
                            "replyTo": {
                              "type": "string",
                              "format": "email",
                              "pattern": "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
                            },
                            "sendingDomain": {
                              "type": "string"
                            },
                            "dns": {
                              "type": "object",
                              "properties": {
                                "spf": {
                                  "default": "pending",
                                  "type": "string",
                                  "enum": ["pending", "verified", "failing"]
                                },
                                "dkim": {
                                  "default": "pending",
                                  "type": "string",
                                  "enum": ["pending", "verified", "failing"]
                                },
                                "dmarc": {
                                  "default": "pending",
                                  "type": "string",
                                  "enum": ["pending", "verified", "failing"]
                                }
                              },
                              "required": ["spf", "dkim", "dmarc"],
                              "additionalProperties": false
                            },
                            "credentialId": {
                              "type": "string"
                            },
                            "syncedLabelIds": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "syncedFolderIds": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            }
                          },
                          "required": ["channel", "provider", "emailAddress"],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "channel": {
                              "type": "string",
                              "const": "instagram"
                            },
                            "instagramBusinessAccountId": {
                              "type": "string"
                            },
                            "instagramPageId": {
                              "type": "string"
                            },
                            "instagramUsername": {
                              "type": "string"
                            }
                          },
                          "required": ["channel", "instagramBusinessAccountId", "instagramPageId"],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "channel": {
                              "type": "string",
                              "const": "google_reviews"
                            },
                            "placeId": {
                              "type": "string"
                            },
                            "businessName": {
                              "type": "string"
                            }
                          },
                          "required": ["channel"],
                          "additionalProperties": false
                        }
                      ]
                    },
                    "aiAgentId": {
                      "anyOf": [
                        {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "aiSettings": {
                      "default": {
                        "enabled": true
                      },
                      "type": "object",
                      "properties": {
                        "enabled": {
                          "default": true,
                          "type": "boolean"
                        },
                        "model": {
                          "type": "string"
                        },
                        "temperature": {
                          "type": "number",
                          "minimum": 0,
                          "maximum": 2
                        },
                        "maxTokens": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "systemPromptOverride": {
                          "type": "string"
                        },
                        "greeting": {
                          "type": "string"
                        },
                        "tone": {
                          "type": "string",
                          "enum": ["professional", "friendly", "casual", "formal"]
                        },
                        "language": {
                          "type": "string"
                        },
                        "additionalInstructions": {
                          "type": "string"
                        },
                        "businessHours": {
                          "type": "object",
                          "properties": {
                            "timezone": {
                              "type": "string"
                            },
                            "schedule": {
                              "type": "object",
                              "properties": {
                                "monday": {
                                  "type": "object",
                                  "properties": {
                                    "start": {
                                      "type": "string"
                                    },
                                    "end": {
                                      "type": "string"
                                    },
                                    "enabled": {
                                      "type": "boolean"
                                    }
                                  },
                                  "required": ["start", "end", "enabled"],
                                  "additionalProperties": false
                                },
                                "tuesday": {
                                  "type": "object",
                                  "properties": {
                                    "start": {
                                      "type": "string"
                                    },
                                    "end": {
                                      "type": "string"
                                    },
                                    "enabled": {
                                      "type": "boolean"
                                    }
                                  },
                                  "required": ["start", "end", "enabled"],
                                  "additionalProperties": false
                                },
                                "wednesday": {
                                  "type": "object",
                                  "properties": {
                                    "start": {
                                      "type": "string"
                                    },
                                    "end": {
                                      "type": "string"
                                    },
                                    "enabled": {
                                      "type": "boolean"
                                    }
                                  },
                                  "required": ["start", "end", "enabled"],
                                  "additionalProperties": false
                                },
                                "thursday": {
                                  "type": "object",
                                  "properties": {
                                    "start": {
                                      "type": "string"
                                    },
                                    "end": {
                                      "type": "string"
                                    },
                                    "enabled": {
                                      "type": "boolean"
                                    }
                                  },
                                  "required": ["start", "end", "enabled"],
                                  "additionalProperties": false
                                },
                                "friday": {
                                  "type": "object",
                                  "properties": {
                                    "start": {
                                      "type": "string"
                                    },
                                    "end": {
                                      "type": "string"
                                    },
                                    "enabled": {
                                      "type": "boolean"
                                    }
                                  },
                                  "required": ["start", "end", "enabled"],
                                  "additionalProperties": false
                                },
                                "saturday": {
                                  "type": "object",
                                  "properties": {
                                    "start": {
                                      "type": "string"
                                    },
                                    "end": {
                                      "type": "string"
                                    },
                                    "enabled": {
                                      "type": "boolean"
                                    }
                                  },
                                  "required": ["start", "end", "enabled"],
                                  "additionalProperties": false
                                },
                                "sunday": {
                                  "type": "object",
                                  "properties": {
                                    "start": {
                                      "type": "string"
                                    },
                                    "end": {
                                      "type": "string"
                                    },
                                    "enabled": {
                                      "type": "boolean"
                                    }
                                  },
                                  "required": ["start", "end", "enabled"],
                                  "additionalProperties": false
                                }
                              },
                              "additionalProperties": false
                            }
                          },
                          "required": ["timezone", "schedule"],
                          "additionalProperties": false
                        },
                        "offHoursMessage": {
                          "type": "string"
                        },
                        "maxAiTurns": {
                          "type": "number",
                          "minimum": 1,
                          "maximum": 50
                        },
                        "allowFileUploads": {
                          "type": "boolean"
                        },
                        "toolOverrides": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "skillId": {
                                "type": "string"
                              },
                              "enabled": {
                                "type": "boolean"
                              }
                            },
                            "required": ["skillId", "enabled"],
                            "additionalProperties": false
                          }
                        },
                        "emailDecision": {
                          "type": "object",
                          "properties": {
                            "replyMode": {
                              "default": "draft",
                              "type": "string",
                              "enum": ["draft", "auto"]
                            },
                            "decisionPrompt": {
                              "type": "string"
                            },
                            "autoReplyMinConfidence": {
                              "default": 0.7,
                              "type": "number",
                              "minimum": 0,
                              "maximum": 1
                            },
                            "firstTimeSenderMode": {
                              "default": "draft",
                              "type": "string",
                              "enum": ["draft", "auto", "ignore"]
                            }
                          },
                          "required": [
                            "replyMode",
                            "autoReplyMinConfidence",
                            "firstTimeSenderMode"
                          ],
                          "additionalProperties": false
                        }
                      },
                      "required": ["enabled"],
                      "additionalProperties": false
                    },
                    "autoResolveOverride": {
                      "anyOf": [
                        {
                          "anyOf": [
                            {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "number"
                                },
                                {
                                  "type": "boolean"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            {
                              "type": "object",
                              "propertyNames": {
                                "type": "string"
                              },
                              "additionalProperties": {}
                            },
                            {
                              "type": "array",
                              "items": {}
                            }
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "defaultAssignee": {
                      "type": "string",
                      "enum": ["ai", "agent", "unassigned"]
                    },
                    "defaultAssigneeId": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "createdAt": {
                      "type": "string"
                    },
                    "updatedAt": {
                      "type": "string"
                    },
                    "deletedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": [
                    "id",
                    "orgId",
                    "name",
                    "channel",
                    "status",
                    "channelConfig",
                    "aiAgentId",
                    "aiSettings",
                    "autoResolveOverride",
                    "defaultAssignee",
                    "defaultAssigneeId",
                    "createdAt",
                    "updatedAt",
                    "deletedAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "inboxes-delete",
        "summary": "Delete an inbox",
        "tags": ["Inboxes"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    }
                  },
                  "required": ["success"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/inboxes/{id}/identity-secret/reveal": {
      "post": {
        "operationId": "inboxes-revealIdentitySecret",
        "summary": "Reveal the widget identity-verification secret (admin only)",
        "tags": ["Inboxes"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  }
                },
                "required": ["orgId"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "secret": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": ["secret"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/contacts": {
      "get": {
        "operationId": "contacts-list",
        "summary": "List contacts",
        "tags": ["Contacts"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "search",
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "identifierValue",
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "tagIds",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          },
          {
            "in": "query",
            "name": "lifecycleStage",
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "limit",
            "schema": {
              "default": 50,
              "type": "integer",
              "minimum": 1,
              "maximum": 100
            }
          },
          {
            "in": "query",
            "name": "offset",
            "schema": {
              "default": 0,
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "contacts": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "orgId": {
                            "type": "string"
                          },
                          "name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "email": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "phone": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "avatar": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "lastSeenCountryCode": {
                            "anyOf": [
                              {
                                "type": "string",
                                "maxLength": 2
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "firstSeenAt": {
                            "type": "string"
                          },
                          "lastSeenAt": {
                            "type": "string"
                          },
                          "lastContactedAt": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "conversationCount": {
                            "type": "integer",
                            "minimum": -2147483648,
                            "maximum": 2147483647
                          },
                          "lifecycleStage": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "tagIds": {
                            "default": [],
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "customAttributes": {
                            "default": {},
                            "type": "object",
                            "propertyNames": {
                              "type": "string"
                            },
                            "additionalProperties": {}
                          },
                          "consent": {
                            "default": {
                              "dataProcessing": false,
                              "marketing": false,
                              "channels": {}
                            },
                            "type": "object",
                            "properties": {
                              "dataProcessing": {
                                "type": "boolean"
                              },
                              "dataProcessingAt": {
                                "type": "string",
                                "format": "date-time",
                                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                              },
                              "dataProcessingVersion": {
                                "type": "string"
                              },
                              "dataProcessingSource": {
                                "type": "string",
                                "enum": [
                                  "widget_explicit",
                                  "host_asserted",
                                  "manual",
                                  "imported",
                                  "legitimate_interest"
                                ]
                              },
                              "marketing": {
                                "type": "boolean"
                              },
                              "marketingAt": {
                                "type": "string",
                                "format": "date-time",
                                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                              },
                              "channels": {
                                "type": "object",
                                "propertyNames": {
                                  "type": "string"
                                },
                                "additionalProperties": {
                                  "type": "string",
                                  "enum": ["opted_in", "opted_out", "not_set"]
                                }
                              },
                              "channelEvidence": {
                                "type": "object",
                                "propertyNames": {
                                  "type": "string"
                                },
                                "additionalProperties": {
                                  "type": "object",
                                  "properties": {
                                    "status": {
                                      "type": "string",
                                      "enum": ["opted_in", "opted_out", "not_set"]
                                    },
                                    "source": {
                                      "type": "string",
                                      "enum": [
                                        "inbound_keyword",
                                        "cross_channel_rule",
                                        "manual",
                                        "imported",
                                        "provider"
                                      ]
                                    },
                                    "recordedAt": {
                                      "type": "string",
                                      "format": "date-time",
                                      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                                    },
                                    "providerEventId": {
                                      "type": "string",
                                      "minLength": 1,
                                      "maxLength": 255
                                    },
                                    "derivedFromChannel": {
                                      "type": "string",
                                      "minLength": 1,
                                      "maxLength": 64
                                    }
                                  },
                                  "required": ["status", "source", "recordedAt"],
                                  "additionalProperties": false
                                }
                              }
                            },
                            "additionalProperties": false
                          },
                          "externalIds": {
                            "default": {},
                            "type": "object",
                            "propertyNames": {
                              "type": "string"
                            },
                            "additionalProperties": {
                              "type": "string"
                            }
                          },
                          "identityProvenance": {
                            "default": {},
                            "type": "object",
                            "properties": {
                              "name": {
                                "type": "object",
                                "properties": {
                                  "source": {
                                    "type": "string",
                                    "enum": [
                                      "widget_self_asserted",
                                      "widget_verified_identity",
                                      "agent",
                                      "import",
                                      "provider"
                                    ]
                                  },
                                  "verified": {
                                    "type": "boolean"
                                  },
                                  "recordedAt": {
                                    "type": "string",
                                    "format": "date-time",
                                    "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                                  }
                                },
                                "required": ["source", "verified", "recordedAt"],
                                "additionalProperties": false
                              },
                              "email": {
                                "type": "object",
                                "properties": {
                                  "source": {
                                    "type": "string",
                                    "enum": [
                                      "widget_self_asserted",
                                      "widget_verified_identity",
                                      "agent",
                                      "import",
                                      "provider"
                                    ]
                                  },
                                  "verified": {
                                    "type": "boolean"
                                  },
                                  "recordedAt": {
                                    "type": "string",
                                    "format": "date-time",
                                    "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                                  }
                                },
                                "required": ["source", "verified", "recordedAt"],
                                "additionalProperties": false
                              },
                              "phone": {
                                "type": "object",
                                "properties": {
                                  "source": {
                                    "type": "string",
                                    "enum": [
                                      "widget_self_asserted",
                                      "widget_verified_identity",
                                      "agent",
                                      "import",
                                      "provider"
                                    ]
                                  },
                                  "verified": {
                                    "type": "boolean"
                                  },
                                  "recordedAt": {
                                    "type": "string",
                                    "format": "date-time",
                                    "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                                  }
                                },
                                "required": ["source", "verified", "recordedAt"],
                                "additionalProperties": false
                              },
                              "company": {
                                "type": "object",
                                "properties": {
                                  "source": {
                                    "type": "string",
                                    "enum": [
                                      "widget_self_asserted",
                                      "widget_verified_identity",
                                      "agent",
                                      "import",
                                      "provider"
                                    ]
                                  },
                                  "verified": {
                                    "type": "boolean"
                                  },
                                  "recordedAt": {
                                    "type": "string",
                                    "format": "date-time",
                                    "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                                  }
                                },
                                "required": ["source", "verified", "recordedAt"],
                                "additionalProperties": false
                              }
                            },
                            "additionalProperties": false
                          },
                          "lastSurveyedAt": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "surveyCount30d": {
                            "type": "integer",
                            "minimum": -2147483648,
                            "maximum": 2147483647
                          },
                          "createdAt": {
                            "type": "string"
                          },
                          "updatedAt": {
                            "type": "string"
                          },
                          "mergedIntoId": {
                            "anyOf": [
                              {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "blockedAt": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "deletedAt": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        },
                        "required": [
                          "id",
                          "orgId",
                          "name",
                          "email",
                          "phone",
                          "avatar",
                          "lastSeenCountryCode",
                          "firstSeenAt",
                          "lastSeenAt",
                          "lastContactedAt",
                          "conversationCount",
                          "lifecycleStage",
                          "tagIds",
                          "customAttributes",
                          "consent",
                          "externalIds",
                          "identityProvenance",
                          "lastSurveyedAt",
                          "surveyCount30d",
                          "createdAt",
                          "updatedAt",
                          "mergedIntoId",
                          "blockedAt",
                          "deletedAt"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "pagination": {
                      "type": "object",
                      "properties": {
                        "total": {
                          "type": "number"
                        },
                        "limit": {
                          "type": "number"
                        },
                        "offset": {
                          "type": "number"
                        }
                      },
                      "required": ["total", "limit", "offset"],
                      "additionalProperties": false
                    }
                  },
                  "required": ["contacts", "pagination"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "contacts-create",
        "summary": "Create a new contact",
        "tags": ["Contacts"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string"
                  },
                  "email": {
                    "type": "string",
                    "format": "email",
                    "pattern": "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
                  },
                  "phone": {
                    "type": "string"
                  },
                  "lifecycleStage": {
                    "type": "string"
                  },
                  "tagIds": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "customAttributes": {
                    "type": "object",
                    "propertyNames": {
                      "type": "string"
                    },
                    "additionalProperties": {}
                  },
                  "externalIds": {
                    "type": "object",
                    "propertyNames": {
                      "type": "string"
                    },
                    "additionalProperties": {
                      "type": "string"
                    }
                  },
                  "avatar": {
                    "type": "string",
                    "format": "uri"
                  },
                  "consent": {
                    "type": "object",
                    "properties": {
                      "dataProcessing": {
                        "type": "boolean"
                      },
                      "dataProcessingAt": {
                        "type": "string",
                        "format": "date-time",
                        "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                      },
                      "dataProcessingVersion": {
                        "type": "string"
                      },
                      "dataProcessingSource": {
                        "type": "string",
                        "enum": [
                          "widget_explicit",
                          "host_asserted",
                          "manual",
                          "imported",
                          "legitimate_interest"
                        ]
                      },
                      "marketing": {
                        "type": "boolean"
                      },
                      "marketingAt": {
                        "type": "string",
                        "format": "date-time",
                        "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                      },
                      "channels": {
                        "type": "object",
                        "propertyNames": {
                          "type": "string"
                        },
                        "additionalProperties": {
                          "type": "string",
                          "enum": ["opted_in", "opted_out", "not_set"]
                        }
                      },
                      "channelEvidence": {
                        "type": "object",
                        "propertyNames": {
                          "type": "string"
                        },
                        "additionalProperties": {
                          "type": "object",
                          "properties": {
                            "status": {
                              "type": "string",
                              "enum": ["opted_in", "opted_out", "not_set"]
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "inbound_keyword",
                                "cross_channel_rule",
                                "manual",
                                "imported",
                                "provider"
                              ]
                            },
                            "recordedAt": {
                              "type": "string",
                              "format": "date-time",
                              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                            },
                            "providerEventId": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 255
                            },
                            "derivedFromChannel": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 64
                            }
                          },
                          "required": ["status", "source", "recordedAt"]
                        }
                      }
                    }
                  }
                },
                "required": ["orgId"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "orgId": {
                      "type": "string"
                    },
                    "name": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "email": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "phone": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "avatar": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "lastSeenCountryCode": {
                      "anyOf": [
                        {
                          "type": "string",
                          "maxLength": 2
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "firstSeenAt": {
                      "type": "string"
                    },
                    "lastSeenAt": {
                      "type": "string"
                    },
                    "lastContactedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "conversationCount": {
                      "type": "integer",
                      "minimum": -2147483648,
                      "maximum": 2147483647
                    },
                    "lifecycleStage": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "tagIds": {
                      "default": [],
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "customAttributes": {
                      "default": {},
                      "type": "object",
                      "propertyNames": {
                        "type": "string"
                      },
                      "additionalProperties": {}
                    },
                    "consent": {
                      "default": {
                        "dataProcessing": false,
                        "marketing": false,
                        "channels": {}
                      },
                      "type": "object",
                      "properties": {
                        "dataProcessing": {
                          "type": "boolean"
                        },
                        "dataProcessingAt": {
                          "type": "string",
                          "format": "date-time",
                          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                        },
                        "dataProcessingVersion": {
                          "type": "string"
                        },
                        "dataProcessingSource": {
                          "type": "string",
                          "enum": [
                            "widget_explicit",
                            "host_asserted",
                            "manual",
                            "imported",
                            "legitimate_interest"
                          ]
                        },
                        "marketing": {
                          "type": "boolean"
                        },
                        "marketingAt": {
                          "type": "string",
                          "format": "date-time",
                          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                        },
                        "channels": {
                          "type": "object",
                          "propertyNames": {
                            "type": "string"
                          },
                          "additionalProperties": {
                            "type": "string",
                            "enum": ["opted_in", "opted_out", "not_set"]
                          }
                        },
                        "channelEvidence": {
                          "type": "object",
                          "propertyNames": {
                            "type": "string"
                          },
                          "additionalProperties": {
                            "type": "object",
                            "properties": {
                              "status": {
                                "type": "string",
                                "enum": ["opted_in", "opted_out", "not_set"]
                              },
                              "source": {
                                "type": "string",
                                "enum": [
                                  "inbound_keyword",
                                  "cross_channel_rule",
                                  "manual",
                                  "imported",
                                  "provider"
                                ]
                              },
                              "recordedAt": {
                                "type": "string",
                                "format": "date-time",
                                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                              },
                              "providerEventId": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 255
                              },
                              "derivedFromChannel": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 64
                              }
                            },
                            "required": ["status", "source", "recordedAt"],
                            "additionalProperties": false
                          }
                        }
                      },
                      "additionalProperties": false
                    },
                    "externalIds": {
                      "default": {},
                      "type": "object",
                      "propertyNames": {
                        "type": "string"
                      },
                      "additionalProperties": {
                        "type": "string"
                      }
                    },
                    "identityProvenance": {
                      "default": {},
                      "type": "object",
                      "properties": {
                        "name": {
                          "type": "object",
                          "properties": {
                            "source": {
                              "type": "string",
                              "enum": [
                                "widget_self_asserted",
                                "widget_verified_identity",
                                "agent",
                                "import",
                                "provider"
                              ]
                            },
                            "verified": {
                              "type": "boolean"
                            },
                            "recordedAt": {
                              "type": "string",
                              "format": "date-time",
                              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                            }
                          },
                          "required": ["source", "verified", "recordedAt"],
                          "additionalProperties": false
                        },
                        "email": {
                          "type": "object",
                          "properties": {
                            "source": {
                              "type": "string",
                              "enum": [
                                "widget_self_asserted",
                                "widget_verified_identity",
                                "agent",
                                "import",
                                "provider"
                              ]
                            },
                            "verified": {
                              "type": "boolean"
                            },
                            "recordedAt": {
                              "type": "string",
                              "format": "date-time",
                              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                            }
                          },
                          "required": ["source", "verified", "recordedAt"],
                          "additionalProperties": false
                        },
                        "phone": {
                          "type": "object",
                          "properties": {
                            "source": {
                              "type": "string",
                              "enum": [
                                "widget_self_asserted",
                                "widget_verified_identity",
                                "agent",
                                "import",
                                "provider"
                              ]
                            },
                            "verified": {
                              "type": "boolean"
                            },
                            "recordedAt": {
                              "type": "string",
                              "format": "date-time",
                              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                            }
                          },
                          "required": ["source", "verified", "recordedAt"],
                          "additionalProperties": false
                        },
                        "company": {
                          "type": "object",
                          "properties": {
                            "source": {
                              "type": "string",
                              "enum": [
                                "widget_self_asserted",
                                "widget_verified_identity",
                                "agent",
                                "import",
                                "provider"
                              ]
                            },
                            "verified": {
                              "type": "boolean"
                            },
                            "recordedAt": {
                              "type": "string",
                              "format": "date-time",
                              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                            }
                          },
                          "required": ["source", "verified", "recordedAt"],
                          "additionalProperties": false
                        }
                      },
                      "additionalProperties": false
                    },
                    "lastSurveyedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "surveyCount30d": {
                      "type": "integer",
                      "minimum": -2147483648,
                      "maximum": 2147483647
                    },
                    "createdAt": {
                      "type": "string"
                    },
                    "updatedAt": {
                      "type": "string"
                    },
                    "mergedIntoId": {
                      "anyOf": [
                        {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "blockedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "deletedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": [
                    "id",
                    "orgId",
                    "name",
                    "email",
                    "phone",
                    "avatar",
                    "lastSeenCountryCode",
                    "firstSeenAt",
                    "lastSeenAt",
                    "lastContactedAt",
                    "conversationCount",
                    "lifecycleStage",
                    "tagIds",
                    "customAttributes",
                    "consent",
                    "externalIds",
                    "identityProvenance",
                    "lastSurveyedAt",
                    "surveyCount30d",
                    "createdAt",
                    "updatedAt",
                    "mergedIntoId",
                    "blockedAt",
                    "deletedAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/contacts/{id}": {
      "get": {
        "operationId": "contacts-get",
        "summary": "Get contact by ID with identifiers",
        "tags": ["Contacts"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "orgId": {
                      "type": "string"
                    },
                    "name": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "email": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "phone": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "avatar": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "lastSeenCountryCode": {
                      "anyOf": [
                        {
                          "type": "string",
                          "maxLength": 2
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "firstSeenAt": {
                      "type": "string"
                    },
                    "lastSeenAt": {
                      "type": "string"
                    },
                    "lastContactedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "conversationCount": {
                      "type": "integer",
                      "minimum": -2147483648,
                      "maximum": 2147483647
                    },
                    "lifecycleStage": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "tagIds": {
                      "default": [],
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "customAttributes": {
                      "default": {},
                      "type": "object",
                      "propertyNames": {
                        "type": "string"
                      },
                      "additionalProperties": {}
                    },
                    "consent": {
                      "default": {
                        "dataProcessing": false,
                        "marketing": false,
                        "channels": {}
                      },
                      "type": "object",
                      "properties": {
                        "dataProcessing": {
                          "type": "boolean"
                        },
                        "dataProcessingAt": {
                          "type": "string",
                          "format": "date-time",
                          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                        },
                        "dataProcessingVersion": {
                          "type": "string"
                        },
                        "dataProcessingSource": {
                          "type": "string",
                          "enum": [
                            "widget_explicit",
                            "host_asserted",
                            "manual",
                            "imported",
                            "legitimate_interest"
                          ]
                        },
                        "marketing": {
                          "type": "boolean"
                        },
                        "marketingAt": {
                          "type": "string",
                          "format": "date-time",
                          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                        },
                        "channels": {
                          "type": "object",
                          "propertyNames": {
                            "type": "string"
                          },
                          "additionalProperties": {
                            "type": "string",
                            "enum": ["opted_in", "opted_out", "not_set"]
                          }
                        },
                        "channelEvidence": {
                          "type": "object",
                          "propertyNames": {
                            "type": "string"
                          },
                          "additionalProperties": {
                            "type": "object",
                            "properties": {
                              "status": {
                                "type": "string",
                                "enum": ["opted_in", "opted_out", "not_set"]
                              },
                              "source": {
                                "type": "string",
                                "enum": [
                                  "inbound_keyword",
                                  "cross_channel_rule",
                                  "manual",
                                  "imported",
                                  "provider"
                                ]
                              },
                              "recordedAt": {
                                "type": "string",
                                "format": "date-time",
                                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                              },
                              "providerEventId": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 255
                              },
                              "derivedFromChannel": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 64
                              }
                            },
                            "required": ["status", "source", "recordedAt"],
                            "additionalProperties": false
                          }
                        }
                      },
                      "additionalProperties": false
                    },
                    "externalIds": {
                      "default": {},
                      "type": "object",
                      "propertyNames": {
                        "type": "string"
                      },
                      "additionalProperties": {
                        "type": "string"
                      }
                    },
                    "identityProvenance": {
                      "default": {},
                      "type": "object",
                      "properties": {
                        "name": {
                          "type": "object",
                          "properties": {
                            "source": {
                              "type": "string",
                              "enum": [
                                "widget_self_asserted",
                                "widget_verified_identity",
                                "agent",
                                "import",
                                "provider"
                              ]
                            },
                            "verified": {
                              "type": "boolean"
                            },
                            "recordedAt": {
                              "type": "string",
                              "format": "date-time",
                              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                            }
                          },
                          "required": ["source", "verified", "recordedAt"],
                          "additionalProperties": false
                        },
                        "email": {
                          "type": "object",
                          "properties": {
                            "source": {
                              "type": "string",
                              "enum": [
                                "widget_self_asserted",
                                "widget_verified_identity",
                                "agent",
                                "import",
                                "provider"
                              ]
                            },
                            "verified": {
                              "type": "boolean"
                            },
                            "recordedAt": {
                              "type": "string",
                              "format": "date-time",
                              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                            }
                          },
                          "required": ["source", "verified", "recordedAt"],
                          "additionalProperties": false
                        },
                        "phone": {
                          "type": "object",
                          "properties": {
                            "source": {
                              "type": "string",
                              "enum": [
                                "widget_self_asserted",
                                "widget_verified_identity",
                                "agent",
                                "import",
                                "provider"
                              ]
                            },
                            "verified": {
                              "type": "boolean"
                            },
                            "recordedAt": {
                              "type": "string",
                              "format": "date-time",
                              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                            }
                          },
                          "required": ["source", "verified", "recordedAt"],
                          "additionalProperties": false
                        },
                        "company": {
                          "type": "object",
                          "properties": {
                            "source": {
                              "type": "string",
                              "enum": [
                                "widget_self_asserted",
                                "widget_verified_identity",
                                "agent",
                                "import",
                                "provider"
                              ]
                            },
                            "verified": {
                              "type": "boolean"
                            },
                            "recordedAt": {
                              "type": "string",
                              "format": "date-time",
                              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                            }
                          },
                          "required": ["source", "verified", "recordedAt"],
                          "additionalProperties": false
                        }
                      },
                      "additionalProperties": false
                    },
                    "lastSurveyedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "surveyCount30d": {
                      "type": "integer",
                      "minimum": -2147483648,
                      "maximum": 2147483647
                    },
                    "createdAt": {
                      "type": "string"
                    },
                    "updatedAt": {
                      "type": "string"
                    },
                    "mergedIntoId": {
                      "anyOf": [
                        {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "blockedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "deletedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "identifierRows": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "orgId": {
                            "type": "string"
                          },
                          "contactId": {
                            "type": "string"
                          },
                          "type": {
                            "type": "string"
                          },
                          "value": {
                            "type": "string"
                          },
                          "channel": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "inboxId": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "verified": {
                            "type": "boolean"
                          },
                          "primary": {
                            "type": "boolean"
                          },
                          "verifiedAt": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "createdAt": {
                            "type": "string"
                          },
                          "updatedAt": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "id",
                          "orgId",
                          "contactId",
                          "type",
                          "value",
                          "channel",
                          "inboxId",
                          "verified",
                          "primary",
                          "verifiedAt",
                          "createdAt",
                          "updatedAt"
                        ],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": [
                    "id",
                    "orgId",
                    "name",
                    "email",
                    "phone",
                    "avatar",
                    "lastSeenCountryCode",
                    "firstSeenAt",
                    "lastSeenAt",
                    "lastContactedAt",
                    "conversationCount",
                    "lifecycleStage",
                    "tagIds",
                    "customAttributes",
                    "consent",
                    "externalIds",
                    "identityProvenance",
                    "lastSurveyedAt",
                    "surveyCount30d",
                    "createdAt",
                    "updatedAt",
                    "mergedIntoId",
                    "blockedAt",
                    "deletedAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "contacts-update",
        "summary": "Update a contact",
        "tags": ["Contacts"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string"
                  },
                  "email": {
                    "type": "string",
                    "format": "email",
                    "pattern": "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
                  },
                  "phone": {
                    "type": "string"
                  },
                  "lifecycleStage": {
                    "type": "string"
                  },
                  "tagIds": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "customAttributes": {
                    "type": "object",
                    "propertyNames": {
                      "type": "string"
                    },
                    "additionalProperties": {}
                  },
                  "externalIds": {
                    "type": "object",
                    "propertyNames": {
                      "type": "string"
                    },
                    "additionalProperties": {
                      "type": "string"
                    }
                  },
                  "consent": {
                    "type": "object",
                    "properties": {
                      "dataProcessing": {
                        "type": "boolean"
                      },
                      "dataProcessingAt": {
                        "type": "string",
                        "format": "date-time",
                        "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                      },
                      "dataProcessingVersion": {
                        "type": "string"
                      },
                      "dataProcessingSource": {
                        "type": "string",
                        "enum": [
                          "widget_explicit",
                          "host_asserted",
                          "manual",
                          "imported",
                          "legitimate_interest"
                        ]
                      },
                      "marketing": {
                        "type": "boolean"
                      },
                      "marketingAt": {
                        "type": "string",
                        "format": "date-time",
                        "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                      },
                      "channels": {
                        "type": "object",
                        "propertyNames": {
                          "type": "string"
                        },
                        "additionalProperties": {
                          "type": "string",
                          "enum": ["opted_in", "opted_out", "not_set"]
                        }
                      },
                      "channelEvidence": {
                        "type": "object",
                        "propertyNames": {
                          "type": "string"
                        },
                        "additionalProperties": {
                          "type": "object",
                          "properties": {
                            "status": {
                              "type": "string",
                              "enum": ["opted_in", "opted_out", "not_set"]
                            },
                            "source": {
                              "type": "string",
                              "enum": [
                                "inbound_keyword",
                                "cross_channel_rule",
                                "manual",
                                "imported",
                                "provider"
                              ]
                            },
                            "recordedAt": {
                              "type": "string",
                              "format": "date-time",
                              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                            },
                            "providerEventId": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 255
                            },
                            "derivedFromChannel": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 64
                            }
                          },
                          "required": ["status", "source", "recordedAt"]
                        }
                      }
                    }
                  },
                  "avatar": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "uri"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                },
                "required": ["orgId"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "orgId": {
                      "type": "string"
                    },
                    "name": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "email": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "phone": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "avatar": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "lastSeenCountryCode": {
                      "anyOf": [
                        {
                          "type": "string",
                          "maxLength": 2
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "firstSeenAt": {
                      "type": "string"
                    },
                    "lastSeenAt": {
                      "type": "string"
                    },
                    "lastContactedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "conversationCount": {
                      "type": "integer",
                      "minimum": -2147483648,
                      "maximum": 2147483647
                    },
                    "lifecycleStage": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "tagIds": {
                      "default": [],
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "customAttributes": {
                      "default": {},
                      "type": "object",
                      "propertyNames": {
                        "type": "string"
                      },
                      "additionalProperties": {}
                    },
                    "consent": {
                      "default": {
                        "dataProcessing": false,
                        "marketing": false,
                        "channels": {}
                      },
                      "type": "object",
                      "properties": {
                        "dataProcessing": {
                          "type": "boolean"
                        },
                        "dataProcessingAt": {
                          "type": "string",
                          "format": "date-time",
                          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                        },
                        "dataProcessingVersion": {
                          "type": "string"
                        },
                        "dataProcessingSource": {
                          "type": "string",
                          "enum": [
                            "widget_explicit",
                            "host_asserted",
                            "manual",
                            "imported",
                            "legitimate_interest"
                          ]
                        },
                        "marketing": {
                          "type": "boolean"
                        },
                        "marketingAt": {
                          "type": "string",
                          "format": "date-time",
                          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                        },
                        "channels": {
                          "type": "object",
                          "propertyNames": {
                            "type": "string"
                          },
                          "additionalProperties": {
                            "type": "string",
                            "enum": ["opted_in", "opted_out", "not_set"]
                          }
                        },
                        "channelEvidence": {
                          "type": "object",
                          "propertyNames": {
                            "type": "string"
                          },
                          "additionalProperties": {
                            "type": "object",
                            "properties": {
                              "status": {
                                "type": "string",
                                "enum": ["opted_in", "opted_out", "not_set"]
                              },
                              "source": {
                                "type": "string",
                                "enum": [
                                  "inbound_keyword",
                                  "cross_channel_rule",
                                  "manual",
                                  "imported",
                                  "provider"
                                ]
                              },
                              "recordedAt": {
                                "type": "string",
                                "format": "date-time",
                                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                              },
                              "providerEventId": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 255
                              },
                              "derivedFromChannel": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 64
                              }
                            },
                            "required": ["status", "source", "recordedAt"],
                            "additionalProperties": false
                          }
                        }
                      },
                      "additionalProperties": false
                    },
                    "externalIds": {
                      "default": {},
                      "type": "object",
                      "propertyNames": {
                        "type": "string"
                      },
                      "additionalProperties": {
                        "type": "string"
                      }
                    },
                    "identityProvenance": {
                      "default": {},
                      "type": "object",
                      "properties": {
                        "name": {
                          "type": "object",
                          "properties": {
                            "source": {
                              "type": "string",
                              "enum": [
                                "widget_self_asserted",
                                "widget_verified_identity",
                                "agent",
                                "import",
                                "provider"
                              ]
                            },
                            "verified": {
                              "type": "boolean"
                            },
                            "recordedAt": {
                              "type": "string",
                              "format": "date-time",
                              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                            }
                          },
                          "required": ["source", "verified", "recordedAt"],
                          "additionalProperties": false
                        },
                        "email": {
                          "type": "object",
                          "properties": {
                            "source": {
                              "type": "string",
                              "enum": [
                                "widget_self_asserted",
                                "widget_verified_identity",
                                "agent",
                                "import",
                                "provider"
                              ]
                            },
                            "verified": {
                              "type": "boolean"
                            },
                            "recordedAt": {
                              "type": "string",
                              "format": "date-time",
                              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                            }
                          },
                          "required": ["source", "verified", "recordedAt"],
                          "additionalProperties": false
                        },
                        "phone": {
                          "type": "object",
                          "properties": {
                            "source": {
                              "type": "string",
                              "enum": [
                                "widget_self_asserted",
                                "widget_verified_identity",
                                "agent",
                                "import",
                                "provider"
                              ]
                            },
                            "verified": {
                              "type": "boolean"
                            },
                            "recordedAt": {
                              "type": "string",
                              "format": "date-time",
                              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                            }
                          },
                          "required": ["source", "verified", "recordedAt"],
                          "additionalProperties": false
                        },
                        "company": {
                          "type": "object",
                          "properties": {
                            "source": {
                              "type": "string",
                              "enum": [
                                "widget_self_asserted",
                                "widget_verified_identity",
                                "agent",
                                "import",
                                "provider"
                              ]
                            },
                            "verified": {
                              "type": "boolean"
                            },
                            "recordedAt": {
                              "type": "string",
                              "format": "date-time",
                              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                            }
                          },
                          "required": ["source", "verified", "recordedAt"],
                          "additionalProperties": false
                        }
                      },
                      "additionalProperties": false
                    },
                    "lastSurveyedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "surveyCount30d": {
                      "type": "integer",
                      "minimum": -2147483648,
                      "maximum": 2147483647
                    },
                    "createdAt": {
                      "type": "string"
                    },
                    "updatedAt": {
                      "type": "string"
                    },
                    "mergedIntoId": {
                      "anyOf": [
                        {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "blockedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "deletedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": [
                    "id",
                    "orgId",
                    "name",
                    "email",
                    "phone",
                    "avatar",
                    "lastSeenCountryCode",
                    "firstSeenAt",
                    "lastSeenAt",
                    "lastContactedAt",
                    "conversationCount",
                    "lifecycleStage",
                    "tagIds",
                    "customAttributes",
                    "consent",
                    "externalIds",
                    "identityProvenance",
                    "lastSurveyedAt",
                    "surveyCount30d",
                    "createdAt",
                    "updatedAt",
                    "mergedIntoId",
                    "blockedAt",
                    "deletedAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "contacts-delete",
        "summary": "Delete a contact (anonymizes PII per GDPR)",
        "tags": ["Contacts"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "erasureStatus": {
                      "type": "string",
                      "const": "pending"
                    }
                  },
                  "required": ["success", "erasureStatus"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/contacts/find": {
      "get": {
        "operationId": "contacts-find",
        "summary": "Find contact by identifier",
        "tags": ["Contacts"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "phone",
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "email",
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "externalIdType",
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "externalIdValue",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "orgId": {
                          "type": "string"
                        },
                        "name": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "email": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "phone": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "avatar": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "lastSeenCountryCode": {
                          "anyOf": [
                            {
                              "type": "string",
                              "maxLength": 2
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "firstSeenAt": {
                          "type": "string"
                        },
                        "lastSeenAt": {
                          "type": "string"
                        },
                        "lastContactedAt": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "conversationCount": {
                          "type": "integer",
                          "minimum": -2147483648,
                          "maximum": 2147483647
                        },
                        "lifecycleStage": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "tagIds": {
                          "default": [],
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "customAttributes": {
                          "default": {},
                          "type": "object",
                          "propertyNames": {
                            "type": "string"
                          },
                          "additionalProperties": {}
                        },
                        "consent": {
                          "default": {
                            "dataProcessing": false,
                            "marketing": false,
                            "channels": {}
                          },
                          "type": "object",
                          "properties": {
                            "dataProcessing": {
                              "type": "boolean"
                            },
                            "dataProcessingAt": {
                              "type": "string",
                              "format": "date-time",
                              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                            },
                            "dataProcessingVersion": {
                              "type": "string"
                            },
                            "dataProcessingSource": {
                              "type": "string",
                              "enum": [
                                "widget_explicit",
                                "host_asserted",
                                "manual",
                                "imported",
                                "legitimate_interest"
                              ]
                            },
                            "marketing": {
                              "type": "boolean"
                            },
                            "marketingAt": {
                              "type": "string",
                              "format": "date-time",
                              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                            },
                            "channels": {
                              "type": "object",
                              "propertyNames": {
                                "type": "string"
                              },
                              "additionalProperties": {
                                "type": "string",
                                "enum": ["opted_in", "opted_out", "not_set"]
                              }
                            },
                            "channelEvidence": {
                              "type": "object",
                              "propertyNames": {
                                "type": "string"
                              },
                              "additionalProperties": {
                                "type": "object",
                                "properties": {
                                  "status": {
                                    "type": "string",
                                    "enum": ["opted_in", "opted_out", "not_set"]
                                  },
                                  "source": {
                                    "type": "string",
                                    "enum": [
                                      "inbound_keyword",
                                      "cross_channel_rule",
                                      "manual",
                                      "imported",
                                      "provider"
                                    ]
                                  },
                                  "recordedAt": {
                                    "type": "string",
                                    "format": "date-time",
                                    "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                                  },
                                  "providerEventId": {
                                    "type": "string",
                                    "minLength": 1,
                                    "maxLength": 255
                                  },
                                  "derivedFromChannel": {
                                    "type": "string",
                                    "minLength": 1,
                                    "maxLength": 64
                                  }
                                },
                                "required": ["status", "source", "recordedAt"],
                                "additionalProperties": false
                              }
                            }
                          },
                          "additionalProperties": false
                        },
                        "externalIds": {
                          "default": {},
                          "type": "object",
                          "propertyNames": {
                            "type": "string"
                          },
                          "additionalProperties": {
                            "type": "string"
                          }
                        },
                        "identityProvenance": {
                          "default": {},
                          "type": "object",
                          "properties": {
                            "name": {
                              "type": "object",
                              "properties": {
                                "source": {
                                  "type": "string",
                                  "enum": [
                                    "widget_self_asserted",
                                    "widget_verified_identity",
                                    "agent",
                                    "import",
                                    "provider"
                                  ]
                                },
                                "verified": {
                                  "type": "boolean"
                                },
                                "recordedAt": {
                                  "type": "string",
                                  "format": "date-time",
                                  "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                                }
                              },
                              "required": ["source", "verified", "recordedAt"],
                              "additionalProperties": false
                            },
                            "email": {
                              "type": "object",
                              "properties": {
                                "source": {
                                  "type": "string",
                                  "enum": [
                                    "widget_self_asserted",
                                    "widget_verified_identity",
                                    "agent",
                                    "import",
                                    "provider"
                                  ]
                                },
                                "verified": {
                                  "type": "boolean"
                                },
                                "recordedAt": {
                                  "type": "string",
                                  "format": "date-time",
                                  "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                                }
                              },
                              "required": ["source", "verified", "recordedAt"],
                              "additionalProperties": false
                            },
                            "phone": {
                              "type": "object",
                              "properties": {
                                "source": {
                                  "type": "string",
                                  "enum": [
                                    "widget_self_asserted",
                                    "widget_verified_identity",
                                    "agent",
                                    "import",
                                    "provider"
                                  ]
                                },
                                "verified": {
                                  "type": "boolean"
                                },
                                "recordedAt": {
                                  "type": "string",
                                  "format": "date-time",
                                  "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                                }
                              },
                              "required": ["source", "verified", "recordedAt"],
                              "additionalProperties": false
                            },
                            "company": {
                              "type": "object",
                              "properties": {
                                "source": {
                                  "type": "string",
                                  "enum": [
                                    "widget_self_asserted",
                                    "widget_verified_identity",
                                    "agent",
                                    "import",
                                    "provider"
                                  ]
                                },
                                "verified": {
                                  "type": "boolean"
                                },
                                "recordedAt": {
                                  "type": "string",
                                  "format": "date-time",
                                  "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                                }
                              },
                              "required": ["source", "verified", "recordedAt"],
                              "additionalProperties": false
                            }
                          },
                          "additionalProperties": false
                        },
                        "lastSurveyedAt": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "surveyCount30d": {
                          "type": "integer",
                          "minimum": -2147483648,
                          "maximum": 2147483647
                        },
                        "createdAt": {
                          "type": "string"
                        },
                        "updatedAt": {
                          "type": "string"
                        },
                        "mergedIntoId": {
                          "anyOf": [
                            {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "blockedAt": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "deletedAt": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      },
                      "required": [
                        "id",
                        "orgId",
                        "name",
                        "email",
                        "phone",
                        "avatar",
                        "lastSeenCountryCode",
                        "firstSeenAt",
                        "lastSeenAt",
                        "lastContactedAt",
                        "conversationCount",
                        "lifecycleStage",
                        "tagIds",
                        "customAttributes",
                        "consent",
                        "externalIds",
                        "identityProvenance",
                        "lastSurveyedAt",
                        "surveyCount30d",
                        "createdAt",
                        "updatedAt",
                        "mergedIntoId",
                        "blockedAt",
                        "deletedAt"
                      ],
                      "additionalProperties": false
                    },
                    {
                      "type": "null"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/contacts/merge": {
      "post": {
        "operationId": "contacts-merge",
        "summary": "Merge two contacts",
        "tags": ["Contacts"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "winnerId": {
                    "type": "string"
                  },
                  "loserId": {
                    "type": "string"
                  }
                },
                "required": ["orgId", "winnerId", "loserId"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "winnerId": {
                      "type": "string"
                    },
                    "mergeLogId": {
                      "type": "string"
                    }
                  },
                  "required": ["winnerId", "mergeLogId"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/contacts/{id}/export": {
      "get": {
        "operationId": "contacts-export",
        "summary": "Export contact data (GDPR)",
        "tags": ["Contacts"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "contact": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "orgId": {
                          "type": "string"
                        },
                        "name": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "email": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "phone": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "avatar": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "lastSeenCountryCode": {
                          "anyOf": [
                            {
                              "type": "string",
                              "maxLength": 2
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "firstSeenAt": {
                          "type": "string"
                        },
                        "lastSeenAt": {
                          "type": "string"
                        },
                        "lastContactedAt": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "conversationCount": {
                          "type": "integer",
                          "minimum": -2147483648,
                          "maximum": 2147483647
                        },
                        "lifecycleStage": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "tagIds": {
                          "default": [],
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "customAttributes": {
                          "default": {},
                          "type": "object",
                          "propertyNames": {
                            "type": "string"
                          },
                          "additionalProperties": {}
                        },
                        "consent": {
                          "default": {
                            "dataProcessing": false,
                            "marketing": false,
                            "channels": {}
                          },
                          "type": "object",
                          "properties": {
                            "dataProcessing": {
                              "type": "boolean"
                            },
                            "dataProcessingAt": {
                              "type": "string",
                              "format": "date-time",
                              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                            },
                            "dataProcessingVersion": {
                              "type": "string"
                            },
                            "dataProcessingSource": {
                              "type": "string",
                              "enum": [
                                "widget_explicit",
                                "host_asserted",
                                "manual",
                                "imported",
                                "legitimate_interest"
                              ]
                            },
                            "marketing": {
                              "type": "boolean"
                            },
                            "marketingAt": {
                              "type": "string",
                              "format": "date-time",
                              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                            },
                            "channels": {
                              "type": "object",
                              "propertyNames": {
                                "type": "string"
                              },
                              "additionalProperties": {
                                "type": "string",
                                "enum": ["opted_in", "opted_out", "not_set"]
                              }
                            },
                            "channelEvidence": {
                              "type": "object",
                              "propertyNames": {
                                "type": "string"
                              },
                              "additionalProperties": {
                                "type": "object",
                                "properties": {
                                  "status": {
                                    "type": "string",
                                    "enum": ["opted_in", "opted_out", "not_set"]
                                  },
                                  "source": {
                                    "type": "string",
                                    "enum": [
                                      "inbound_keyword",
                                      "cross_channel_rule",
                                      "manual",
                                      "imported",
                                      "provider"
                                    ]
                                  },
                                  "recordedAt": {
                                    "type": "string",
                                    "format": "date-time",
                                    "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                                  },
                                  "providerEventId": {
                                    "type": "string",
                                    "minLength": 1,
                                    "maxLength": 255
                                  },
                                  "derivedFromChannel": {
                                    "type": "string",
                                    "minLength": 1,
                                    "maxLength": 64
                                  }
                                },
                                "required": ["status", "source", "recordedAt"],
                                "additionalProperties": false
                              }
                            }
                          },
                          "additionalProperties": false
                        },
                        "externalIds": {
                          "default": {},
                          "type": "object",
                          "propertyNames": {
                            "type": "string"
                          },
                          "additionalProperties": {
                            "type": "string"
                          }
                        },
                        "identityProvenance": {
                          "default": {},
                          "type": "object",
                          "properties": {
                            "name": {
                              "type": "object",
                              "properties": {
                                "source": {
                                  "type": "string",
                                  "enum": [
                                    "widget_self_asserted",
                                    "widget_verified_identity",
                                    "agent",
                                    "import",
                                    "provider"
                                  ]
                                },
                                "verified": {
                                  "type": "boolean"
                                },
                                "recordedAt": {
                                  "type": "string",
                                  "format": "date-time",
                                  "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                                }
                              },
                              "required": ["source", "verified", "recordedAt"],
                              "additionalProperties": false
                            },
                            "email": {
                              "type": "object",
                              "properties": {
                                "source": {
                                  "type": "string",
                                  "enum": [
                                    "widget_self_asserted",
                                    "widget_verified_identity",
                                    "agent",
                                    "import",
                                    "provider"
                                  ]
                                },
                                "verified": {
                                  "type": "boolean"
                                },
                                "recordedAt": {
                                  "type": "string",
                                  "format": "date-time",
                                  "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                                }
                              },
                              "required": ["source", "verified", "recordedAt"],
                              "additionalProperties": false
                            },
                            "phone": {
                              "type": "object",
                              "properties": {
                                "source": {
                                  "type": "string",
                                  "enum": [
                                    "widget_self_asserted",
                                    "widget_verified_identity",
                                    "agent",
                                    "import",
                                    "provider"
                                  ]
                                },
                                "verified": {
                                  "type": "boolean"
                                },
                                "recordedAt": {
                                  "type": "string",
                                  "format": "date-time",
                                  "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                                }
                              },
                              "required": ["source", "verified", "recordedAt"],
                              "additionalProperties": false
                            },
                            "company": {
                              "type": "object",
                              "properties": {
                                "source": {
                                  "type": "string",
                                  "enum": [
                                    "widget_self_asserted",
                                    "widget_verified_identity",
                                    "agent",
                                    "import",
                                    "provider"
                                  ]
                                },
                                "verified": {
                                  "type": "boolean"
                                },
                                "recordedAt": {
                                  "type": "string",
                                  "format": "date-time",
                                  "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                                }
                              },
                              "required": ["source", "verified", "recordedAt"],
                              "additionalProperties": false
                            }
                          },
                          "additionalProperties": false
                        },
                        "lastSurveyedAt": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "surveyCount30d": {
                          "type": "integer",
                          "minimum": -2147483648,
                          "maximum": 2147483647
                        },
                        "createdAt": {
                          "type": "string"
                        },
                        "updatedAt": {
                          "type": "string"
                        },
                        "mergedIntoId": {
                          "anyOf": [
                            {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "blockedAt": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "deletedAt": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "tags": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        }
                      },
                      "required": [
                        "id",
                        "orgId",
                        "name",
                        "email",
                        "phone",
                        "avatar",
                        "lastSeenCountryCode",
                        "firstSeenAt",
                        "lastSeenAt",
                        "lastContactedAt",
                        "conversationCount",
                        "lifecycleStage",
                        "tagIds",
                        "customAttributes",
                        "consent",
                        "externalIds",
                        "identityProvenance",
                        "lastSurveyedAt",
                        "surveyCount30d",
                        "createdAt",
                        "updatedAt",
                        "mergedIntoId",
                        "blockedAt",
                        "deletedAt",
                        "tags"
                      ],
                      "additionalProperties": false
                    },
                    "identifiers": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "orgId": {
                            "type": "string"
                          },
                          "contactId": {
                            "type": "string"
                          },
                          "type": {
                            "type": "string"
                          },
                          "value": {
                            "type": "string"
                          },
                          "channel": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "inboxId": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "verified": {
                            "type": "boolean"
                          },
                          "primary": {
                            "type": "boolean"
                          },
                          "verifiedAt": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "createdAt": {
                            "type": "string"
                          },
                          "updatedAt": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "id",
                          "orgId",
                          "contactId",
                          "type",
                          "value",
                          "channel",
                          "inboxId",
                          "verified",
                          "primary",
                          "verifiedAt",
                          "createdAt",
                          "updatedAt"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "conversations": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "channel": {
                            "type": "string"
                          },
                          "status": {
                            "type": "string"
                          },
                          "createdAt": {
                            "type": "string"
                          }
                        },
                        "required": ["id", "channel", "status", "createdAt"],
                        "additionalProperties": false
                      }
                    },
                    "messages": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "conversationId": {
                            "type": "string"
                          },
                          "role": {
                            "type": "string"
                          },
                          "content": {
                            "type": "string"
                          },
                          "contentType": {
                            "type": "string"
                          },
                          "createdAt": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "id",
                          "conversationId",
                          "role",
                          "content",
                          "contentType",
                          "createdAt"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "mergeHistory": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "mergeReason": {
                            "type": "string"
                          },
                          "createdAt": {
                            "type": "string"
                          }
                        },
                        "required": ["id", "mergeReason", "createdAt"],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": [
                    "contact",
                    "identifiers",
                    "conversations",
                    "messages",
                    "mergeHistory"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/contacts/{id}/anonymize": {
      "post": {
        "operationId": "contacts-anonymize",
        "summary": "Anonymize contact (GDPR erasure)",
        "tags": ["Contacts"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  }
                },
                "required": ["orgId"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "erasureStatus": {
                      "type": "string",
                      "const": "pending"
                    }
                  },
                  "required": ["success", "erasureStatus"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/contacts/{id}/block": {
      "post": {
        "operationId": "contacts-block",
        "summary": "Block a contact",
        "tags": ["Contacts"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  }
                },
                "required": ["orgId"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    }
                  },
                  "required": ["success"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/contacts/{id}/unblock": {
      "post": {
        "operationId": "contacts-unblock",
        "summary": "Unblock a contact",
        "tags": ["Contacts"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  }
                },
                "required": ["orgId"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    }
                  },
                  "required": ["success"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/conversations": {
      "get": {
        "operationId": "conversations-list",
        "summary": "List conversations",
        "tags": ["Conversations"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "status",
            "schema": {
              "type": "string",
              "enum": ["open", "pending", "snoozed", "resolved"]
            }
          },
          {
            "in": "query",
            "name": "statuses",
            "schema": {
              "type": "array",
              "items": {
                "type": "string",
                "enum": ["open", "pending", "snoozed", "resolved"]
              }
            }
          },
          {
            "in": "query",
            "name": "assigneeType",
            "schema": {
              "type": "string",
              "enum": ["ai", "agent", "unassigned"]
            }
          },
          {
            "in": "query",
            "name": "assigneeId",
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "inboxId",
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "channel",
            "schema": {
              "type": "string",
              "enum": ["voice", "sms", "whatsapp", "chat", "email", "instagram", "google_reviews"]
            }
          },
          {
            "in": "query",
            "name": "priority",
            "schema": {
              "type": "string",
              "enum": ["low", "medium", "high", "urgent"]
            }
          },
          {
            "in": "query",
            "name": "labelIds",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          },
          {
            "in": "query",
            "name": "contactId",
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "needsApproval",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "in": "query",
            "name": "createdAfter",
            "schema": {
              "type": "string",
              "format": "date-time",
              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
            }
          },
          {
            "in": "query",
            "name": "search",
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          },
          {
            "in": "query",
            "name": "cursor",
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          },
          {
            "in": "query",
            "name": "sortBy",
            "schema": {
              "default": "lastActivityAt",
              "type": "string",
              "enum": ["lastActivityAt", "createdAt", "priority"]
            }
          },
          {
            "in": "query",
            "name": "sortDirection",
            "schema": {
              "default": "desc",
              "type": "string",
              "enum": ["asc", "desc"]
            }
          },
          {
            "in": "query",
            "name": "limit",
            "schema": {
              "default": 50,
              "type": "integer",
              "minimum": 1,
              "maximum": 100
            }
          },
          {
            "in": "query",
            "name": "offset",
            "schema": {
              "default": 0,
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "conversations": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "orgId": {
                            "type": "string"
                          },
                          "inboxId": {
                            "type": "string"
                          },
                          "contactId": {
                            "type": "string"
                          },
                          "displayId": {
                            "type": "integer",
                            "minimum": -2147483648,
                            "maximum": 2147483647
                          },
                          "subject": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "status": {
                            "type": "string",
                            "enum": ["open", "pending", "snoozed", "resolved"]
                          },
                          "priority": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": ["low", "medium", "high", "urgent"]
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "assigneeType": {
                            "type": "string",
                            "enum": ["ai", "agent", "unassigned"]
                          },
                          "assigneeId": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "channel": {
                            "type": "string",
                            "enum": [
                              "voice",
                              "sms",
                              "whatsapp",
                              "chat",
                              "email",
                              "instagram",
                              "google_reviews"
                            ]
                          },
                          "inbound": {
                            "type": "boolean"
                          },
                          "lastActivityAt": {
                            "type": "string"
                          },
                          "firstResponseAt": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "resolvedAt": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "snoozedUntil": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "outcome": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "outcomeData": {
                            "anyOf": [
                              {
                                "default": null,
                                "anyOf": [
                                  {
                                    "type": "object",
                                    "propertyNames": {
                                      "type": "string"
                                    },
                                    "additionalProperties": {}
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "labelIds": {
                            "default": [],
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "externalIds": {
                            "default": {},
                            "type": "object",
                            "propertyNames": {
                              "type": "string"
                            },
                            "additionalProperties": {
                              "type": "string"
                            }
                          },
                          "messageCount": {
                            "type": "integer",
                            "minimum": -2147483648,
                            "maximum": 2147483647
                          },
                          "unreadCount": {
                            "type": "integer",
                            "minimum": -2147483648,
                            "maximum": 2147483647
                          },
                          "autoResolveStage": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": ["candidate", "gate", "follow_up", "warning", "grace"]
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "autoResolveCandidateAt": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "autoResolvePaused": {
                            "type": "boolean"
                          },
                          "agentLockUntil": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "channelWindowExpiresAt": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "relatedConversationId": {
                            "anyOf": [
                              {},
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "workflowRunId": {
                            "anyOf": [
                              {},
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "reopenCount": {
                            "type": "integer",
                            "minimum": -2147483648,
                            "maximum": 2147483647
                          },
                          "version": {
                            "type": "integer",
                            "minimum": -2147483648,
                            "maximum": 2147483647
                          },
                          "createdAt": {
                            "type": "string"
                          },
                          "updatedAt": {
                            "type": "string"
                          },
                          "contactLastReadAt": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "agentLastReadAt": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "deletedAt": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "contactName": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "contactPhone": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "contactEmail": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "contactAvatar": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "hasPendingDraft": {
                            "type": "boolean"
                          },
                          "lastMessagePreview": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        },
                        "required": [
                          "id",
                          "orgId",
                          "inboxId",
                          "contactId",
                          "displayId",
                          "subject",
                          "status",
                          "priority",
                          "assigneeType",
                          "assigneeId",
                          "channel",
                          "inbound",
                          "lastActivityAt",
                          "firstResponseAt",
                          "resolvedAt",
                          "snoozedUntil",
                          "outcome",
                          "outcomeData",
                          "labelIds",
                          "externalIds",
                          "messageCount",
                          "unreadCount",
                          "autoResolveStage",
                          "autoResolveCandidateAt",
                          "autoResolvePaused",
                          "agentLockUntil",
                          "channelWindowExpiresAt",
                          "relatedConversationId",
                          "workflowRunId",
                          "reopenCount",
                          "version",
                          "createdAt",
                          "updatedAt",
                          "contactLastReadAt",
                          "agentLastReadAt",
                          "deletedAt"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "pagination": {
                      "type": "object",
                      "properties": {
                        "total": {
                          "type": "number"
                        },
                        "limit": {
                          "type": "number"
                        },
                        "offset": {
                          "type": "number"
                        },
                        "nextCursor": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      },
                      "required": ["total", "limit", "offset"],
                      "additionalProperties": false
                    }
                  },
                  "required": ["conversations", "pagination"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "conversations-create",
        "summary": "Create a new conversation",
        "tags": ["Conversations"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "inboxId": {
                    "type": "string"
                  },
                  "contactId": {
                    "type": "string"
                  },
                  "subject": {
                    "type": "string"
                  },
                  "channel": {
                    "type": "string",
                    "enum": [
                      "voice",
                      "sms",
                      "whatsapp",
                      "chat",
                      "email",
                      "instagram",
                      "google_reviews"
                    ]
                  },
                  "inbound": {
                    "default": true,
                    "type": "boolean"
                  },
                  "assigneeType": {
                    "type": "string",
                    "enum": ["ai", "agent", "unassigned"]
                  },
                  "assigneeId": {
                    "type": "string"
                  },
                  "priority": {
                    "type": "string",
                    "enum": ["low", "medium", "high", "urgent"]
                  },
                  "labelIds": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "externalIds": {
                    "type": "object",
                    "propertyNames": {
                      "type": "string"
                    },
                    "additionalProperties": {
                      "type": "string"
                    }
                  }
                },
                "required": ["orgId", "inboxId", "contactId", "channel"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "orgId": {
                      "type": "string"
                    },
                    "inboxId": {
                      "type": "string"
                    },
                    "contactId": {
                      "type": "string"
                    },
                    "displayId": {
                      "type": "integer",
                      "minimum": -2147483648,
                      "maximum": 2147483647
                    },
                    "subject": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "status": {
                      "type": "string",
                      "enum": ["open", "pending", "snoozed", "resolved"]
                    },
                    "priority": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": ["low", "medium", "high", "urgent"]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "assigneeType": {
                      "type": "string",
                      "enum": ["ai", "agent", "unassigned"]
                    },
                    "assigneeId": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "channel": {
                      "type": "string",
                      "enum": [
                        "voice",
                        "sms",
                        "whatsapp",
                        "chat",
                        "email",
                        "instagram",
                        "google_reviews"
                      ]
                    },
                    "inbound": {
                      "type": "boolean"
                    },
                    "lastActivityAt": {
                      "type": "string"
                    },
                    "firstResponseAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "resolvedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "snoozedUntil": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "outcome": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "outcomeData": {
                      "anyOf": [
                        {
                          "default": null,
                          "anyOf": [
                            {
                              "type": "object",
                              "propertyNames": {
                                "type": "string"
                              },
                              "additionalProperties": {}
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "labelIds": {
                      "default": [],
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "externalIds": {
                      "default": {},
                      "type": "object",
                      "propertyNames": {
                        "type": "string"
                      },
                      "additionalProperties": {
                        "type": "string"
                      }
                    },
                    "messageCount": {
                      "type": "integer",
                      "minimum": -2147483648,
                      "maximum": 2147483647
                    },
                    "unreadCount": {
                      "type": "integer",
                      "minimum": -2147483648,
                      "maximum": 2147483647
                    },
                    "autoResolveStage": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": ["candidate", "gate", "follow_up", "warning", "grace"]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "autoResolveCandidateAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "autoResolvePaused": {
                      "type": "boolean"
                    },
                    "agentLockUntil": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "channelWindowExpiresAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "relatedConversationId": {
                      "anyOf": [
                        {},
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "workflowRunId": {
                      "anyOf": [
                        {},
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "reopenCount": {
                      "type": "integer",
                      "minimum": -2147483648,
                      "maximum": 2147483647
                    },
                    "version": {
                      "type": "integer",
                      "minimum": -2147483648,
                      "maximum": 2147483647
                    },
                    "createdAt": {
                      "type": "string"
                    },
                    "updatedAt": {
                      "type": "string"
                    },
                    "contactLastReadAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "agentLastReadAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "deletedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": [
                    "id",
                    "orgId",
                    "inboxId",
                    "contactId",
                    "displayId",
                    "subject",
                    "status",
                    "priority",
                    "assigneeType",
                    "assigneeId",
                    "channel",
                    "inbound",
                    "lastActivityAt",
                    "firstResponseAt",
                    "resolvedAt",
                    "snoozedUntil",
                    "outcome",
                    "outcomeData",
                    "labelIds",
                    "externalIds",
                    "messageCount",
                    "unreadCount",
                    "autoResolveStage",
                    "autoResolveCandidateAt",
                    "autoResolvePaused",
                    "agentLockUntil",
                    "channelWindowExpiresAt",
                    "relatedConversationId",
                    "workflowRunId",
                    "reopenCount",
                    "version",
                    "createdAt",
                    "updatedAt",
                    "contactLastReadAt",
                    "agentLastReadAt",
                    "deletedAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/conversations/{id}": {
      "get": {
        "operationId": "conversations-get",
        "summary": "Get conversation by ID",
        "tags": ["Conversations"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "orgId": {
                      "type": "string"
                    },
                    "inboxId": {
                      "type": "string"
                    },
                    "contactId": {
                      "type": "string"
                    },
                    "displayId": {
                      "type": "integer",
                      "minimum": -2147483648,
                      "maximum": 2147483647
                    },
                    "subject": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "status": {
                      "type": "string",
                      "enum": ["open", "pending", "snoozed", "resolved"]
                    },
                    "priority": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": ["low", "medium", "high", "urgent"]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "assigneeType": {
                      "type": "string",
                      "enum": ["ai", "agent", "unassigned"]
                    },
                    "assigneeId": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "channel": {
                      "type": "string",
                      "enum": [
                        "voice",
                        "sms",
                        "whatsapp",
                        "chat",
                        "email",
                        "instagram",
                        "google_reviews"
                      ]
                    },
                    "inbound": {
                      "type": "boolean"
                    },
                    "lastActivityAt": {
                      "type": "string"
                    },
                    "firstResponseAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "resolvedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "snoozedUntil": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "outcome": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "outcomeData": {
                      "anyOf": [
                        {
                          "default": null,
                          "anyOf": [
                            {
                              "type": "object",
                              "propertyNames": {
                                "type": "string"
                              },
                              "additionalProperties": {}
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "labelIds": {
                      "default": [],
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "externalIds": {
                      "default": {},
                      "type": "object",
                      "propertyNames": {
                        "type": "string"
                      },
                      "additionalProperties": {
                        "type": "string"
                      }
                    },
                    "messageCount": {
                      "type": "integer",
                      "minimum": -2147483648,
                      "maximum": 2147483647
                    },
                    "unreadCount": {
                      "type": "integer",
                      "minimum": -2147483648,
                      "maximum": 2147483647
                    },
                    "autoResolveStage": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": ["candidate", "gate", "follow_up", "warning", "grace"]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "autoResolveCandidateAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "autoResolvePaused": {
                      "type": "boolean"
                    },
                    "agentLockUntil": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "channelWindowExpiresAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "relatedConversationId": {
                      "anyOf": [
                        {},
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "workflowRunId": {
                      "anyOf": [
                        {},
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "reopenCount": {
                      "type": "integer",
                      "minimum": -2147483648,
                      "maximum": 2147483647
                    },
                    "version": {
                      "type": "integer",
                      "minimum": -2147483648,
                      "maximum": 2147483647
                    },
                    "createdAt": {
                      "type": "string"
                    },
                    "updatedAt": {
                      "type": "string"
                    },
                    "contactLastReadAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "agentLastReadAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "deletedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "inbox": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "orgId": {
                          "type": "string"
                        },
                        "name": {
                          "type": "string"
                        },
                        "channel": {
                          "type": "string",
                          "enum": [
                            "voice",
                            "sms",
                            "whatsapp",
                            "chat",
                            "email",
                            "instagram",
                            "google_reviews"
                          ]
                        },
                        "status": {
                          "type": "string",
                          "enum": ["active", "paused", "disabled"]
                        },
                        "channelConfig": {
                          "default": {},
                          "anyOf": [
                            {
                              "type": "object",
                              "properties": {
                                "channel": {
                                  "type": "string",
                                  "const": "voice"
                                },
                                "phoneNumber": {
                                  "type": "string"
                                },
                                "twilioPhoneNumberSid": {
                                  "type": "string"
                                },
                                "elevenlabsAgentId": {
                                  "type": "string"
                                },
                                "maxConcurrentCalls": {
                                  "default": 5,
                                  "type": "integer",
                                  "minimum": -9007199254740991,
                                  "maximum": 9007199254740991
                                },
                                "recordCalls": {
                                  "default": false,
                                  "type": "boolean"
                                }
                              },
                              "required": [
                                "channel",
                                "phoneNumber",
                                "twilioPhoneNumberSid",
                                "maxConcurrentCalls",
                                "recordCalls"
                              ],
                              "additionalProperties": false
                            },
                            {
                              "type": "object",
                              "properties": {
                                "channel": {
                                  "type": "string",
                                  "const": "sms"
                                },
                                "phoneNumber": {
                                  "type": "string"
                                },
                                "twilioPhoneNumberSid": {
                                  "type": "string"
                                }
                              },
                              "required": ["channel", "phoneNumber", "twilioPhoneNumberSid"],
                              "additionalProperties": false
                            },
                            {
                              "type": "object",
                              "properties": {
                                "channel": {
                                  "type": "string",
                                  "const": "whatsapp"
                                },
                                "metaPhoneNumberId": {
                                  "type": "string"
                                },
                                "phoneNumber": {
                                  "type": "string"
                                },
                                "phoneNumberDisplayName": {
                                  "type": "string"
                                },
                                "whatsappBusinessAccountId": {
                                  "type": "string"
                                },
                                "facebookPageId": {
                                  "type": "string"
                                }
                              },
                              "required": ["channel", "metaPhoneNumberId", "phoneNumber"],
                              "additionalProperties": false
                            },
                            {
                              "type": "object",
                              "properties": {
                                "channel": {
                                  "type": "string",
                                  "const": "chat"
                                },
                                "widgetId": {
                                  "type": "string"
                                },
                                "allowedOrigins": {
                                  "type": "array",
                                  "items": {
                                    "type": "string"
                                  }
                                },
                                "theme": {
                                  "type": "object",
                                  "properties": {
                                    "primaryColor": {
                                      "type": "string"
                                    },
                                    "position": {
                                      "type": "string",
                                      "enum": ["bottom-right", "bottom-left"]
                                    },
                                    "template": {
                                      "type": "string"
                                    },
                                    "backgroundColor": {
                                      "type": "string"
                                    },
                                    "textColor": {
                                      "type": "string"
                                    },
                                    "userBubbleColor": {
                                      "type": "string"
                                    },
                                    "userBubbleTextColor": {
                                      "type": "string"
                                    },
                                    "fontFamily": {
                                      "type": "string"
                                    },
                                    "fontSize": {
                                      "type": "string",
                                      "enum": ["sm", "base", "lg"]
                                    },
                                    "messageStyle": {
                                      "type": "string",
                                      "enum": ["plain", "bubble"]
                                    },
                                    "logoUrl": {
                                      "type": "string"
                                    },
                                    "headerTitle": {
                                      "type": "string"
                                    },
                                    "poweredBy": {
                                      "type": "boolean"
                                    }
                                  },
                                  "additionalProperties": false
                                },
                                "privacyPolicyUrl": {
                                  "type": "string",
                                  "maxLength": 2048,
                                  "format": "uri"
                                },
                                "identityVerificationConfigured": {
                                  "type": "boolean"
                                }
                              },
                              "required": ["channel"],
                              "additionalProperties": false
                            },
                            {
                              "type": "object",
                              "properties": {
                                "channel": {
                                  "type": "string",
                                  "const": "email"
                                },
                                "provider": {
                                  "default": "smtp",
                                  "type": "string",
                                  "enum": ["smtp", "gmail", "microsoft"]
                                },
                                "emailAddress": {
                                  "type": "string",
                                  "format": "email",
                                  "pattern": "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
                                },
                                "inboundAddress": {
                                  "type": "string",
                                  "format": "email",
                                  "pattern": "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
                                },
                                "fromName": {
                                  "type": "string"
                                },
                                "replyTo": {
                                  "type": "string",
                                  "format": "email",
                                  "pattern": "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
                                },
                                "sendingDomain": {
                                  "type": "string"
                                },
                                "dns": {
                                  "type": "object",
                                  "properties": {
                                    "spf": {
                                      "default": "pending",
                                      "type": "string",
                                      "enum": ["pending", "verified", "failing"]
                                    },
                                    "dkim": {
                                      "default": "pending",
                                      "type": "string",
                                      "enum": ["pending", "verified", "failing"]
                                    },
                                    "dmarc": {
                                      "default": "pending",
                                      "type": "string",
                                      "enum": ["pending", "verified", "failing"]
                                    }
                                  },
                                  "required": ["spf", "dkim", "dmarc"],
                                  "additionalProperties": false
                                },
                                "credentialId": {
                                  "type": "string"
                                },
                                "syncedLabelIds": {
                                  "type": "array",
                                  "items": {
                                    "type": "string"
                                  }
                                },
                                "syncedFolderIds": {
                                  "type": "array",
                                  "items": {
                                    "type": "string"
                                  }
                                }
                              },
                              "required": ["channel", "provider", "emailAddress"],
                              "additionalProperties": false
                            },
                            {
                              "type": "object",
                              "properties": {
                                "channel": {
                                  "type": "string",
                                  "const": "instagram"
                                },
                                "instagramBusinessAccountId": {
                                  "type": "string"
                                },
                                "instagramPageId": {
                                  "type": "string"
                                },
                                "instagramUsername": {
                                  "type": "string"
                                }
                              },
                              "required": [
                                "channel",
                                "instagramBusinessAccountId",
                                "instagramPageId"
                              ],
                              "additionalProperties": false
                            },
                            {
                              "type": "object",
                              "properties": {
                                "channel": {
                                  "type": "string",
                                  "const": "google_reviews"
                                },
                                "placeId": {
                                  "type": "string"
                                },
                                "businessName": {
                                  "type": "string"
                                }
                              },
                              "required": ["channel"],
                              "additionalProperties": false
                            }
                          ]
                        },
                        "aiAgentId": {
                          "anyOf": [
                            {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "aiSettings": {
                          "default": {
                            "enabled": true
                          },
                          "type": "object",
                          "properties": {
                            "enabled": {
                              "default": true,
                              "type": "boolean"
                            },
                            "model": {
                              "type": "string"
                            },
                            "temperature": {
                              "type": "number",
                              "minimum": 0,
                              "maximum": 2
                            },
                            "maxTokens": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991
                            },
                            "systemPromptOverride": {
                              "type": "string"
                            },
                            "greeting": {
                              "type": "string"
                            },
                            "tone": {
                              "type": "string",
                              "enum": ["professional", "friendly", "casual", "formal"]
                            },
                            "language": {
                              "type": "string"
                            },
                            "additionalInstructions": {
                              "type": "string"
                            },
                            "businessHours": {
                              "type": "object",
                              "properties": {
                                "timezone": {
                                  "type": "string"
                                },
                                "schedule": {
                                  "type": "object",
                                  "properties": {
                                    "monday": {
                                      "type": "object",
                                      "properties": {
                                        "start": {
                                          "type": "string"
                                        },
                                        "end": {
                                          "type": "string"
                                        },
                                        "enabled": {
                                          "type": "boolean"
                                        }
                                      },
                                      "required": ["start", "end", "enabled"],
                                      "additionalProperties": false
                                    },
                                    "tuesday": {
                                      "type": "object",
                                      "properties": {
                                        "start": {
                                          "type": "string"
                                        },
                                        "end": {
                                          "type": "string"
                                        },
                                        "enabled": {
                                          "type": "boolean"
                                        }
                                      },
                                      "required": ["start", "end", "enabled"],
                                      "additionalProperties": false
                                    },
                                    "wednesday": {
                                      "type": "object",
                                      "properties": {
                                        "start": {
                                          "type": "string"
                                        },
                                        "end": {
                                          "type": "string"
                                        },
                                        "enabled": {
                                          "type": "boolean"
                                        }
                                      },
                                      "required": ["start", "end", "enabled"],
                                      "additionalProperties": false
                                    },
                                    "thursday": {
                                      "type": "object",
                                      "properties": {
                                        "start": {
                                          "type": "string"
                                        },
                                        "end": {
                                          "type": "string"
                                        },
                                        "enabled": {
                                          "type": "boolean"
                                        }
                                      },
                                      "required": ["start", "end", "enabled"],
                                      "additionalProperties": false
                                    },
                                    "friday": {
                                      "type": "object",
                                      "properties": {
                                        "start": {
                                          "type": "string"
                                        },
                                        "end": {
                                          "type": "string"
                                        },
                                        "enabled": {
                                          "type": "boolean"
                                        }
                                      },
                                      "required": ["start", "end", "enabled"],
                                      "additionalProperties": false
                                    },
                                    "saturday": {
                                      "type": "object",
                                      "properties": {
                                        "start": {
                                          "type": "string"
                                        },
                                        "end": {
                                          "type": "string"
                                        },
                                        "enabled": {
                                          "type": "boolean"
                                        }
                                      },
                                      "required": ["start", "end", "enabled"],
                                      "additionalProperties": false
                                    },
                                    "sunday": {
                                      "type": "object",
                                      "properties": {
                                        "start": {
                                          "type": "string"
                                        },
                                        "end": {
                                          "type": "string"
                                        },
                                        "enabled": {
                                          "type": "boolean"
                                        }
                                      },
                                      "required": ["start", "end", "enabled"],
                                      "additionalProperties": false
                                    }
                                  },
                                  "additionalProperties": false
                                }
                              },
                              "required": ["timezone", "schedule"],
                              "additionalProperties": false
                            },
                            "offHoursMessage": {
                              "type": "string"
                            },
                            "maxAiTurns": {
                              "type": "number",
                              "minimum": 1,
                              "maximum": 50
                            },
                            "allowFileUploads": {
                              "type": "boolean"
                            },
                            "toolOverrides": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "skillId": {
                                    "type": "string"
                                  },
                                  "enabled": {
                                    "type": "boolean"
                                  }
                                },
                                "required": ["skillId", "enabled"],
                                "additionalProperties": false
                              }
                            },
                            "emailDecision": {
                              "type": "object",
                              "properties": {
                                "replyMode": {
                                  "default": "draft",
                                  "type": "string",
                                  "enum": ["draft", "auto"]
                                },
                                "decisionPrompt": {
                                  "type": "string"
                                },
                                "autoReplyMinConfidence": {
                                  "default": 0.7,
                                  "type": "number",
                                  "minimum": 0,
                                  "maximum": 1
                                },
                                "firstTimeSenderMode": {
                                  "default": "draft",
                                  "type": "string",
                                  "enum": ["draft", "auto", "ignore"]
                                }
                              },
                              "required": [
                                "replyMode",
                                "autoReplyMinConfidence",
                                "firstTimeSenderMode"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": ["enabled"],
                          "additionalProperties": false
                        },
                        "autoResolveOverride": {
                          "anyOf": [
                            {
                              "anyOf": [
                                {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "number"
                                    },
                                    {
                                      "type": "boolean"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                {
                                  "type": "object",
                                  "propertyNames": {
                                    "type": "string"
                                  },
                                  "additionalProperties": {}
                                },
                                {
                                  "type": "array",
                                  "items": {}
                                }
                              ]
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "defaultAssignee": {
                          "type": "string",
                          "enum": ["ai", "agent", "unassigned"]
                        },
                        "defaultAssigneeId": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "createdAt": {
                          "type": "string"
                        },
                        "updatedAt": {
                          "type": "string"
                        },
                        "deletedAt": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      },
                      "required": [
                        "id",
                        "orgId",
                        "name",
                        "channel",
                        "status",
                        "channelConfig",
                        "aiAgentId",
                        "aiSettings",
                        "autoResolveOverride",
                        "defaultAssignee",
                        "defaultAssigneeId",
                        "createdAt",
                        "updatedAt",
                        "deletedAt"
                      ],
                      "additionalProperties": false
                    },
                    "contact": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "orgId": {
                          "type": "string"
                        },
                        "name": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "email": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "phone": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "avatar": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "lastSeenCountryCode": {
                          "anyOf": [
                            {
                              "type": "string",
                              "maxLength": 2
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "firstSeenAt": {
                          "type": "string"
                        },
                        "lastSeenAt": {
                          "type": "string"
                        },
                        "lastContactedAt": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "conversationCount": {
                          "type": "integer",
                          "minimum": -2147483648,
                          "maximum": 2147483647
                        },
                        "lifecycleStage": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "tagIds": {
                          "default": [],
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "customAttributes": {
                          "default": {},
                          "type": "object",
                          "propertyNames": {
                            "type": "string"
                          },
                          "additionalProperties": {}
                        },
                        "consent": {
                          "default": {
                            "dataProcessing": false,
                            "marketing": false,
                            "channels": {}
                          },
                          "type": "object",
                          "properties": {
                            "dataProcessing": {
                              "type": "boolean"
                            },
                            "dataProcessingAt": {
                              "type": "string",
                              "format": "date-time",
                              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                            },
                            "dataProcessingVersion": {
                              "type": "string"
                            },
                            "dataProcessingSource": {
                              "type": "string",
                              "enum": [
                                "widget_explicit",
                                "host_asserted",
                                "manual",
                                "imported",
                                "legitimate_interest"
                              ]
                            },
                            "marketing": {
                              "type": "boolean"
                            },
                            "marketingAt": {
                              "type": "string",
                              "format": "date-time",
                              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                            },
                            "channels": {
                              "type": "object",
                              "propertyNames": {
                                "type": "string"
                              },
                              "additionalProperties": {
                                "type": "string",
                                "enum": ["opted_in", "opted_out", "not_set"]
                              }
                            },
                            "channelEvidence": {
                              "type": "object",
                              "propertyNames": {
                                "type": "string"
                              },
                              "additionalProperties": {
                                "type": "object",
                                "properties": {
                                  "status": {
                                    "type": "string",
                                    "enum": ["opted_in", "opted_out", "not_set"]
                                  },
                                  "source": {
                                    "type": "string",
                                    "enum": [
                                      "inbound_keyword",
                                      "cross_channel_rule",
                                      "manual",
                                      "imported",
                                      "provider"
                                    ]
                                  },
                                  "recordedAt": {
                                    "type": "string",
                                    "format": "date-time",
                                    "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                                  },
                                  "providerEventId": {
                                    "type": "string",
                                    "minLength": 1,
                                    "maxLength": 255
                                  },
                                  "derivedFromChannel": {
                                    "type": "string",
                                    "minLength": 1,
                                    "maxLength": 64
                                  }
                                },
                                "required": ["status", "source", "recordedAt"],
                                "additionalProperties": false
                              }
                            }
                          },
                          "additionalProperties": false
                        },
                        "externalIds": {
                          "default": {},
                          "type": "object",
                          "propertyNames": {
                            "type": "string"
                          },
                          "additionalProperties": {
                            "type": "string"
                          }
                        },
                        "identityProvenance": {
                          "default": {},
                          "type": "object",
                          "properties": {
                            "name": {
                              "type": "object",
                              "properties": {
                                "source": {
                                  "type": "string",
                                  "enum": [
                                    "widget_self_asserted",
                                    "widget_verified_identity",
                                    "agent",
                                    "import",
                                    "provider"
                                  ]
                                },
                                "verified": {
                                  "type": "boolean"
                                },
                                "recordedAt": {
                                  "type": "string",
                                  "format": "date-time",
                                  "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                                }
                              },
                              "required": ["source", "verified", "recordedAt"],
                              "additionalProperties": false
                            },
                            "email": {
                              "type": "object",
                              "properties": {
                                "source": {
                                  "type": "string",
                                  "enum": [
                                    "widget_self_asserted",
                                    "widget_verified_identity",
                                    "agent",
                                    "import",
                                    "provider"
                                  ]
                                },
                                "verified": {
                                  "type": "boolean"
                                },
                                "recordedAt": {
                                  "type": "string",
                                  "format": "date-time",
                                  "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                                }
                              },
                              "required": ["source", "verified", "recordedAt"],
                              "additionalProperties": false
                            },
                            "phone": {
                              "type": "object",
                              "properties": {
                                "source": {
                                  "type": "string",
                                  "enum": [
                                    "widget_self_asserted",
                                    "widget_verified_identity",
                                    "agent",
                                    "import",
                                    "provider"
                                  ]
                                },
                                "verified": {
                                  "type": "boolean"
                                },
                                "recordedAt": {
                                  "type": "string",
                                  "format": "date-time",
                                  "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                                }
                              },
                              "required": ["source", "verified", "recordedAt"],
                              "additionalProperties": false
                            },
                            "company": {
                              "type": "object",
                              "properties": {
                                "source": {
                                  "type": "string",
                                  "enum": [
                                    "widget_self_asserted",
                                    "widget_verified_identity",
                                    "agent",
                                    "import",
                                    "provider"
                                  ]
                                },
                                "verified": {
                                  "type": "boolean"
                                },
                                "recordedAt": {
                                  "type": "string",
                                  "format": "date-time",
                                  "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                                }
                              },
                              "required": ["source", "verified", "recordedAt"],
                              "additionalProperties": false
                            }
                          },
                          "additionalProperties": false
                        },
                        "lastSurveyedAt": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "surveyCount30d": {
                          "type": "integer",
                          "minimum": -2147483648,
                          "maximum": 2147483647
                        },
                        "createdAt": {
                          "type": "string"
                        },
                        "updatedAt": {
                          "type": "string"
                        },
                        "mergedIntoId": {
                          "anyOf": [
                            {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "blockedAt": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "deletedAt": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      },
                      "required": [
                        "id",
                        "orgId",
                        "name",
                        "email",
                        "phone",
                        "avatar",
                        "lastSeenCountryCode",
                        "firstSeenAt",
                        "lastSeenAt",
                        "lastContactedAt",
                        "conversationCount",
                        "lifecycleStage",
                        "tagIds",
                        "customAttributes",
                        "consent",
                        "externalIds",
                        "identityProvenance",
                        "lastSurveyedAt",
                        "surveyCount30d",
                        "createdAt",
                        "updatedAt",
                        "mergedIntoId",
                        "blockedAt",
                        "deletedAt"
                      ],
                      "additionalProperties": false
                    },
                    "labels": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "orgId": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "color": {
                            "type": "string"
                          },
                          "description": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "createdAt": {
                            "type": "string"
                          },
                          "updatedAt": {
                            "type": "string"
                          },
                          "deletedAt": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        },
                        "required": [
                          "id",
                          "orgId",
                          "name",
                          "color",
                          "description",
                          "createdAt",
                          "updatedAt",
                          "deletedAt"
                        ],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": [
                    "id",
                    "orgId",
                    "inboxId",
                    "contactId",
                    "displayId",
                    "subject",
                    "status",
                    "priority",
                    "assigneeType",
                    "assigneeId",
                    "channel",
                    "inbound",
                    "lastActivityAt",
                    "firstResponseAt",
                    "resolvedAt",
                    "snoozedUntil",
                    "outcome",
                    "outcomeData",
                    "labelIds",
                    "externalIds",
                    "messageCount",
                    "unreadCount",
                    "autoResolveStage",
                    "autoResolveCandidateAt",
                    "autoResolvePaused",
                    "agentLockUntil",
                    "channelWindowExpiresAt",
                    "relatedConversationId",
                    "workflowRunId",
                    "reopenCount",
                    "version",
                    "createdAt",
                    "updatedAt",
                    "contactLastReadAt",
                    "agentLastReadAt",
                    "deletedAt",
                    "inbox",
                    "contact",
                    "labels"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "conversations-update",
        "summary": "Update a conversation",
        "tags": ["Conversations"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "version": {
                    "type": "integer",
                    "minimum": -9007199254740991,
                    "maximum": 9007199254740991
                  },
                  "subject": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "status": {
                    "type": "string",
                    "enum": ["open", "pending", "snoozed", "resolved"]
                  },
                  "priority": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": ["low", "medium", "high", "urgent"]
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "assigneeType": {
                    "type": "string",
                    "enum": ["ai", "agent", "unassigned"]
                  },
                  "assigneeId": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "snoozedUntil": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "date-time",
                        "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "outcome": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "outcomeData": {
                    "anyOf": [
                      {
                        "type": "object",
                        "propertyNames": {
                          "type": "string"
                        },
                        "additionalProperties": {}
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "labelIds": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                },
                "required": ["orgId", "version"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "orgId": {
                      "type": "string"
                    },
                    "inboxId": {
                      "type": "string"
                    },
                    "contactId": {
                      "type": "string"
                    },
                    "displayId": {
                      "type": "integer",
                      "minimum": -2147483648,
                      "maximum": 2147483647
                    },
                    "subject": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "status": {
                      "type": "string",
                      "enum": ["open", "pending", "snoozed", "resolved"]
                    },
                    "priority": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": ["low", "medium", "high", "urgent"]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "assigneeType": {
                      "type": "string",
                      "enum": ["ai", "agent", "unassigned"]
                    },
                    "assigneeId": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "channel": {
                      "type": "string",
                      "enum": [
                        "voice",
                        "sms",
                        "whatsapp",
                        "chat",
                        "email",
                        "instagram",
                        "google_reviews"
                      ]
                    },
                    "inbound": {
                      "type": "boolean"
                    },
                    "lastActivityAt": {
                      "type": "string"
                    },
                    "firstResponseAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "resolvedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "snoozedUntil": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "outcome": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "outcomeData": {
                      "anyOf": [
                        {
                          "default": null,
                          "anyOf": [
                            {
                              "type": "object",
                              "propertyNames": {
                                "type": "string"
                              },
                              "additionalProperties": {}
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "labelIds": {
                      "default": [],
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "externalIds": {
                      "default": {},
                      "type": "object",
                      "propertyNames": {
                        "type": "string"
                      },
                      "additionalProperties": {
                        "type": "string"
                      }
                    },
                    "messageCount": {
                      "type": "integer",
                      "minimum": -2147483648,
                      "maximum": 2147483647
                    },
                    "unreadCount": {
                      "type": "integer",
                      "minimum": -2147483648,
                      "maximum": 2147483647
                    },
                    "autoResolveStage": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": ["candidate", "gate", "follow_up", "warning", "grace"]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "autoResolveCandidateAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "autoResolvePaused": {
                      "type": "boolean"
                    },
                    "agentLockUntil": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "channelWindowExpiresAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "relatedConversationId": {
                      "anyOf": [
                        {},
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "workflowRunId": {
                      "anyOf": [
                        {},
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "reopenCount": {
                      "type": "integer",
                      "minimum": -2147483648,
                      "maximum": 2147483647
                    },
                    "version": {
                      "type": "integer",
                      "minimum": -2147483648,
                      "maximum": 2147483647
                    },
                    "createdAt": {
                      "type": "string"
                    },
                    "updatedAt": {
                      "type": "string"
                    },
                    "contactLastReadAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "agentLastReadAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "deletedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": [
                    "id",
                    "orgId",
                    "inboxId",
                    "contactId",
                    "displayId",
                    "subject",
                    "status",
                    "priority",
                    "assigneeType",
                    "assigneeId",
                    "channel",
                    "inbound",
                    "lastActivityAt",
                    "firstResponseAt",
                    "resolvedAt",
                    "snoozedUntil",
                    "outcome",
                    "outcomeData",
                    "labelIds",
                    "externalIds",
                    "messageCount",
                    "unreadCount",
                    "autoResolveStage",
                    "autoResolveCandidateAt",
                    "autoResolvePaused",
                    "agentLockUntil",
                    "channelWindowExpiresAt",
                    "relatedConversationId",
                    "workflowRunId",
                    "reopenCount",
                    "version",
                    "createdAt",
                    "updatedAt",
                    "contactLastReadAt",
                    "agentLastReadAt",
                    "deletedAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "conversations-delete",
        "summary": "Delete a conversation",
        "tags": ["Conversations"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    }
                  },
                  "required": ["success"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/conversations/{id}/assign": {
      "post": {
        "operationId": "conversations-assign",
        "summary": "Assign a conversation",
        "tags": ["Conversations"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "version": {
                    "type": "integer",
                    "minimum": -9007199254740991,
                    "maximum": 9007199254740991
                  },
                  "assigneeType": {
                    "type": "string",
                    "enum": ["ai", "agent", "unassigned"]
                  },
                  "assigneeId": {
                    "type": "string"
                  }
                },
                "required": ["orgId", "version", "assigneeType"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "orgId": {
                      "type": "string"
                    },
                    "inboxId": {
                      "type": "string"
                    },
                    "contactId": {
                      "type": "string"
                    },
                    "displayId": {
                      "type": "integer",
                      "minimum": -2147483648,
                      "maximum": 2147483647
                    },
                    "subject": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "status": {
                      "type": "string",
                      "enum": ["open", "pending", "snoozed", "resolved"]
                    },
                    "priority": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": ["low", "medium", "high", "urgent"]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "assigneeType": {
                      "type": "string",
                      "enum": ["ai", "agent", "unassigned"]
                    },
                    "assigneeId": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "channel": {
                      "type": "string",
                      "enum": [
                        "voice",
                        "sms",
                        "whatsapp",
                        "chat",
                        "email",
                        "instagram",
                        "google_reviews"
                      ]
                    },
                    "inbound": {
                      "type": "boolean"
                    },
                    "lastActivityAt": {
                      "type": "string"
                    },
                    "firstResponseAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "resolvedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "snoozedUntil": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "outcome": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "outcomeData": {
                      "anyOf": [
                        {
                          "default": null,
                          "anyOf": [
                            {
                              "type": "object",
                              "propertyNames": {
                                "type": "string"
                              },
                              "additionalProperties": {}
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "labelIds": {
                      "default": [],
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "externalIds": {
                      "default": {},
                      "type": "object",
                      "propertyNames": {
                        "type": "string"
                      },
                      "additionalProperties": {
                        "type": "string"
                      }
                    },
                    "messageCount": {
                      "type": "integer",
                      "minimum": -2147483648,
                      "maximum": 2147483647
                    },
                    "unreadCount": {
                      "type": "integer",
                      "minimum": -2147483648,
                      "maximum": 2147483647
                    },
                    "autoResolveStage": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": ["candidate", "gate", "follow_up", "warning", "grace"]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "autoResolveCandidateAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "autoResolvePaused": {
                      "type": "boolean"
                    },
                    "agentLockUntil": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "channelWindowExpiresAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "relatedConversationId": {
                      "anyOf": [
                        {},
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "workflowRunId": {
                      "anyOf": [
                        {},
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "reopenCount": {
                      "type": "integer",
                      "minimum": -2147483648,
                      "maximum": 2147483647
                    },
                    "version": {
                      "type": "integer",
                      "minimum": -2147483648,
                      "maximum": 2147483647
                    },
                    "createdAt": {
                      "type": "string"
                    },
                    "updatedAt": {
                      "type": "string"
                    },
                    "contactLastReadAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "agentLastReadAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "deletedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": [
                    "id",
                    "orgId",
                    "inboxId",
                    "contactId",
                    "displayId",
                    "subject",
                    "status",
                    "priority",
                    "assigneeType",
                    "assigneeId",
                    "channel",
                    "inbound",
                    "lastActivityAt",
                    "firstResponseAt",
                    "resolvedAt",
                    "snoozedUntil",
                    "outcome",
                    "outcomeData",
                    "labelIds",
                    "externalIds",
                    "messageCount",
                    "unreadCount",
                    "autoResolveStage",
                    "autoResolveCandidateAt",
                    "autoResolvePaused",
                    "agentLockUntil",
                    "channelWindowExpiresAt",
                    "relatedConversationId",
                    "workflowRunId",
                    "reopenCount",
                    "version",
                    "createdAt",
                    "updatedAt",
                    "contactLastReadAt",
                    "agentLastReadAt",
                    "deletedAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/conversations/{id}/resolve": {
      "post": {
        "operationId": "conversations-resolve",
        "summary": "Resolve a conversation",
        "tags": ["Conversations"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "version": {
                    "type": "integer",
                    "minimum": -9007199254740991,
                    "maximum": 9007199254740991
                  },
                  "outcome": {
                    "type": "string"
                  },
                  "outcomeData": {
                    "type": "object",
                    "propertyNames": {
                      "type": "string"
                    },
                    "additionalProperties": {}
                  }
                },
                "required": ["orgId", "version"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "orgId": {
                      "type": "string"
                    },
                    "inboxId": {
                      "type": "string"
                    },
                    "contactId": {
                      "type": "string"
                    },
                    "displayId": {
                      "type": "integer",
                      "minimum": -2147483648,
                      "maximum": 2147483647
                    },
                    "subject": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "status": {
                      "type": "string",
                      "enum": ["open", "pending", "snoozed", "resolved"]
                    },
                    "priority": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": ["low", "medium", "high", "urgent"]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "assigneeType": {
                      "type": "string",
                      "enum": ["ai", "agent", "unassigned"]
                    },
                    "assigneeId": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "channel": {
                      "type": "string",
                      "enum": [
                        "voice",
                        "sms",
                        "whatsapp",
                        "chat",
                        "email",
                        "instagram",
                        "google_reviews"
                      ]
                    },
                    "inbound": {
                      "type": "boolean"
                    },
                    "lastActivityAt": {
                      "type": "string"
                    },
                    "firstResponseAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "resolvedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "snoozedUntil": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "outcome": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "outcomeData": {
                      "anyOf": [
                        {
                          "default": null,
                          "anyOf": [
                            {
                              "type": "object",
                              "propertyNames": {
                                "type": "string"
                              },
                              "additionalProperties": {}
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "labelIds": {
                      "default": [],
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "externalIds": {
                      "default": {},
                      "type": "object",
                      "propertyNames": {
                        "type": "string"
                      },
                      "additionalProperties": {
                        "type": "string"
                      }
                    },
                    "messageCount": {
                      "type": "integer",
                      "minimum": -2147483648,
                      "maximum": 2147483647
                    },
                    "unreadCount": {
                      "type": "integer",
                      "minimum": -2147483648,
                      "maximum": 2147483647
                    },
                    "autoResolveStage": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": ["candidate", "gate", "follow_up", "warning", "grace"]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "autoResolveCandidateAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "autoResolvePaused": {
                      "type": "boolean"
                    },
                    "agentLockUntil": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "channelWindowExpiresAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "relatedConversationId": {
                      "anyOf": [
                        {},
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "workflowRunId": {
                      "anyOf": [
                        {},
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "reopenCount": {
                      "type": "integer",
                      "minimum": -2147483648,
                      "maximum": 2147483647
                    },
                    "version": {
                      "type": "integer",
                      "minimum": -2147483648,
                      "maximum": 2147483647
                    },
                    "createdAt": {
                      "type": "string"
                    },
                    "updatedAt": {
                      "type": "string"
                    },
                    "contactLastReadAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "agentLastReadAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "deletedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": [
                    "id",
                    "orgId",
                    "inboxId",
                    "contactId",
                    "displayId",
                    "subject",
                    "status",
                    "priority",
                    "assigneeType",
                    "assigneeId",
                    "channel",
                    "inbound",
                    "lastActivityAt",
                    "firstResponseAt",
                    "resolvedAt",
                    "snoozedUntil",
                    "outcome",
                    "outcomeData",
                    "labelIds",
                    "externalIds",
                    "messageCount",
                    "unreadCount",
                    "autoResolveStage",
                    "autoResolveCandidateAt",
                    "autoResolvePaused",
                    "agentLockUntil",
                    "channelWindowExpiresAt",
                    "relatedConversationId",
                    "workflowRunId",
                    "reopenCount",
                    "version",
                    "createdAt",
                    "updatedAt",
                    "contactLastReadAt",
                    "agentLastReadAt",
                    "deletedAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/conversations/{id}/snooze": {
      "post": {
        "operationId": "conversations-snooze",
        "summary": "Snooze a conversation",
        "tags": ["Conversations"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "version": {
                    "type": "integer",
                    "minimum": -9007199254740991,
                    "maximum": 9007199254740991
                  },
                  "until": {
                    "type": "string",
                    "format": "date-time",
                    "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                  }
                },
                "required": ["orgId", "version", "until"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "orgId": {
                      "type": "string"
                    },
                    "inboxId": {
                      "type": "string"
                    },
                    "contactId": {
                      "type": "string"
                    },
                    "displayId": {
                      "type": "integer",
                      "minimum": -2147483648,
                      "maximum": 2147483647
                    },
                    "subject": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "status": {
                      "type": "string",
                      "enum": ["open", "pending", "snoozed", "resolved"]
                    },
                    "priority": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": ["low", "medium", "high", "urgent"]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "assigneeType": {
                      "type": "string",
                      "enum": ["ai", "agent", "unassigned"]
                    },
                    "assigneeId": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "channel": {
                      "type": "string",
                      "enum": [
                        "voice",
                        "sms",
                        "whatsapp",
                        "chat",
                        "email",
                        "instagram",
                        "google_reviews"
                      ]
                    },
                    "inbound": {
                      "type": "boolean"
                    },
                    "lastActivityAt": {
                      "type": "string"
                    },
                    "firstResponseAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "resolvedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "snoozedUntil": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "outcome": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "outcomeData": {
                      "anyOf": [
                        {
                          "default": null,
                          "anyOf": [
                            {
                              "type": "object",
                              "propertyNames": {
                                "type": "string"
                              },
                              "additionalProperties": {}
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "labelIds": {
                      "default": [],
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "externalIds": {
                      "default": {},
                      "type": "object",
                      "propertyNames": {
                        "type": "string"
                      },
                      "additionalProperties": {
                        "type": "string"
                      }
                    },
                    "messageCount": {
                      "type": "integer",
                      "minimum": -2147483648,
                      "maximum": 2147483647
                    },
                    "unreadCount": {
                      "type": "integer",
                      "minimum": -2147483648,
                      "maximum": 2147483647
                    },
                    "autoResolveStage": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": ["candidate", "gate", "follow_up", "warning", "grace"]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "autoResolveCandidateAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "autoResolvePaused": {
                      "type": "boolean"
                    },
                    "agentLockUntil": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "channelWindowExpiresAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "relatedConversationId": {
                      "anyOf": [
                        {},
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "workflowRunId": {
                      "anyOf": [
                        {},
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "reopenCount": {
                      "type": "integer",
                      "minimum": -2147483648,
                      "maximum": 2147483647
                    },
                    "version": {
                      "type": "integer",
                      "minimum": -2147483648,
                      "maximum": 2147483647
                    },
                    "createdAt": {
                      "type": "string"
                    },
                    "updatedAt": {
                      "type": "string"
                    },
                    "contactLastReadAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "agentLastReadAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "deletedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": [
                    "id",
                    "orgId",
                    "inboxId",
                    "contactId",
                    "displayId",
                    "subject",
                    "status",
                    "priority",
                    "assigneeType",
                    "assigneeId",
                    "channel",
                    "inbound",
                    "lastActivityAt",
                    "firstResponseAt",
                    "resolvedAt",
                    "snoozedUntil",
                    "outcome",
                    "outcomeData",
                    "labelIds",
                    "externalIds",
                    "messageCount",
                    "unreadCount",
                    "autoResolveStage",
                    "autoResolveCandidateAt",
                    "autoResolvePaused",
                    "agentLockUntil",
                    "channelWindowExpiresAt",
                    "relatedConversationId",
                    "workflowRunId",
                    "reopenCount",
                    "version",
                    "createdAt",
                    "updatedAt",
                    "contactLastReadAt",
                    "agentLastReadAt",
                    "deletedAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/conversations/batch": {
      "post": {
        "operationId": "conversations-batchUpdate",
        "summary": "Batch update conversations",
        "tags": ["Conversations"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "conversationIds": {
                    "minItems": 1,
                    "maxItems": 100,
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "action": {
                    "type": "string",
                    "enum": ["changeStatus", "assign", "delete"]
                  },
                  "status": {
                    "type": "string",
                    "enum": ["open", "pending", "snoozed", "resolved"]
                  },
                  "assigneeType": {
                    "type": "string",
                    "enum": ["ai", "agent", "unassigned"]
                  },
                  "assigneeId": {
                    "type": "string"
                  }
                },
                "required": ["orgId", "conversationIds", "action"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "updatedCount": {
                      "type": "number"
                    },
                    "requestedCount": {
                      "type": "number"
                    }
                  },
                  "required": ["success", "updatedCount", "requestedCount"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/conversations/{id}/auto-resolve/pause": {
      "post": {
        "operationId": "conversations-pauseAutoResolve",
        "summary": "Pause auto-resolution for a conversation",
        "tags": ["Conversations", "Auto-Resolve"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  }
                },
                "required": ["orgId"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    }
                  },
                  "required": ["success"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/conversations/{id}/auto-resolve/resume": {
      "post": {
        "operationId": "conversations-resumeAutoResolve",
        "summary": "Resume auto-resolution for a conversation",
        "tags": ["Conversations", "Auto-Resolve"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  }
                },
                "required": ["orgId"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    }
                  },
                  "required": ["success"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/conversations/{id}/agent-composing": {
      "post": {
        "operationId": "conversations-setAgentComposing",
        "summary": "Set agent composing lock (prevents auto-resolve)",
        "tags": ["Conversations", "Auto-Resolve"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "durationMs": {
                    "default": 300000,
                    "type": "integer",
                    "minimum": 1000,
                    "maximum": 600000
                  }
                },
                "required": ["orgId"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    }
                  },
                  "required": ["success"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/conversations/{id}/auto-resolve/candidate": {
      "post": {
        "operationId": "conversations-markCandidate",
        "summary": "Mark conversation as resolution candidate",
        "tags": ["Conversations", "Auto-Resolve"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "aiConfidence": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 1
                  }
                },
                "required": ["orgId", "aiConfidence"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "accepted": {
                      "type": "boolean"
                    }
                  },
                  "required": ["accepted"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/conversations/{id}/auto-resolve/cancel": {
      "post": {
        "operationId": "conversations-cancelPipeline",
        "summary": "Cancel the auto-resolve pipeline",
        "tags": ["Conversations", "Auto-Resolve"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  }
                },
                "required": ["orgId"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    }
                  },
                  "required": ["success"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/messages": {
      "get": {
        "operationId": "messages-list",
        "summary": "List messages in a conversation",
        "tags": ["Messages"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "conversationId",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "limit",
            "schema": {
              "default": 50,
              "type": "integer",
              "minimum": 1,
              "maximum": 100
            }
          },
          {
            "in": "query",
            "name": "before",
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "after",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "messages": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "conversationId": {
                            "type": "string"
                          },
                          "role": {
                            "type": "string",
                            "enum": ["contact", "ai", "agent", "system"]
                          },
                          "senderId": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "senderName": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "content": {
                            "type": "string"
                          },
                          "contentType": {
                            "type": "string"
                          },
                          "attachments": {
                            "anyOf": [
                              {
                                "default": null,
                                "anyOf": [
                                  {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "id": {
                                          "type": "string"
                                        },
                                        "type": {
                                          "type": "string",
                                          "enum": ["image", "audio", "video", "file"]
                                        },
                                        "name": {
                                          "type": "string"
                                        },
                                        "mimeType": {
                                          "type": "string"
                                        },
                                        "size": {
                                          "type": "integer",
                                          "minimum": -9007199254740991,
                                          "maximum": 9007199254740991
                                        },
                                        "url": {
                                          "type": "string",
                                          "minLength": 1
                                        }
                                      },
                                      "required": ["id", "type", "name", "mimeType", "size", "url"],
                                      "additionalProperties": false
                                    }
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "status": {
                            "type": "string",
                            "enum": ["pending", "sent", "delivered", "read", "failed", "draft"]
                          },
                          "statusUpdatedAt": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "aiMetadata": {
                            "anyOf": [
                              {
                                "default": null,
                                "anyOf": [
                                  {
                                    "type": "object",
                                    "properties": {
                                      "deliveryRevision": {
                                        "type": "integer",
                                        "exclusiveMinimum": 0,
                                        "maximum": 9007199254740991
                                      },
                                      "model": {
                                        "type": "string"
                                      },
                                      "provider": {
                                        "type": "string",
                                        "enum": [
                                          "openai",
                                          "anthropic",
                                          "bedrock",
                                          "perplexity",
                                          "google",
                                          "builtin"
                                        ]
                                      },
                                      "toolCalls": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "id": {
                                              "type": "string"
                                            },
                                            "name": {
                                              "type": "string"
                                            },
                                            "arguments": {
                                              "type": "object",
                                              "propertyNames": {
                                                "type": "string"
                                              },
                                              "additionalProperties": {}
                                            },
                                            "result": {},
                                            "status": {
                                              "type": "string",
                                              "enum": ["pending", "completed", "failed"]
                                            },
                                            "error": {
                                              "type": "string"
                                            },
                                            "durationMs": {
                                              "type": "integer",
                                              "minimum": -9007199254740991,
                                              "maximum": 9007199254740991
                                            }
                                          },
                                          "required": ["id", "name", "arguments", "status"],
                                          "additionalProperties": false
                                        }
                                      },
                                      "usage": {
                                        "type": "object",
                                        "properties": {
                                          "inputTokens": {
                                            "type": "integer",
                                            "minimum": -9007199254740991,
                                            "maximum": 9007199254740991
                                          },
                                          "outputTokens": {
                                            "type": "integer",
                                            "minimum": -9007199254740991,
                                            "maximum": 9007199254740991
                                          },
                                          "prompt": {
                                            "type": "integer",
                                            "minimum": -9007199254740991,
                                            "maximum": 9007199254740991
                                          },
                                          "completion": {
                                            "type": "integer",
                                            "minimum": -9007199254740991,
                                            "maximum": 9007199254740991
                                          },
                                          "total": {
                                            "type": "integer",
                                            "minimum": -9007199254740991,
                                            "maximum": 9007199254740991
                                          }
                                        },
                                        "required": ["inputTokens", "outputTokens"],
                                        "additionalProperties": false
                                      },
                                      "latencyMs": {
                                        "type": "integer",
                                        "minimum": -9007199254740991,
                                        "maximum": 9007199254740991
                                      },
                                      "components": {
                                        "type": "object",
                                        "properties": {
                                          "quickReplies": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "label": {
                                                  "type": "string"
                                                },
                                                "value": {
                                                  "type": "string"
                                                }
                                              },
                                              "required": ["label", "value"],
                                              "additionalProperties": false
                                            }
                                          },
                                          "card": {
                                            "type": "object",
                                            "properties": {
                                              "title": {
                                                "type": "string"
                                              },
                                              "subtitle": {
                                                "type": "string"
                                              },
                                              "fields": {
                                                "type": "array",
                                                "items": {
                                                  "type": "object",
                                                  "properties": {
                                                    "label": {
                                                      "type": "string"
                                                    },
                                                    "value": {
                                                      "type": "string"
                                                    }
                                                  },
                                                  "required": ["label", "value"],
                                                  "additionalProperties": false
                                                }
                                              }
                                            },
                                            "required": ["title"],
                                            "additionalProperties": false
                                          },
                                          "cards": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "title": {
                                                  "type": "string"
                                                },
                                                "subtitle": {
                                                  "type": "string"
                                                },
                                                "fields": {
                                                  "type": "array",
                                                  "items": {
                                                    "type": "object",
                                                    "properties": {
                                                      "label": {
                                                        "type": "string"
                                                      },
                                                      "value": {
                                                        "type": "string"
                                                      }
                                                    },
                                                    "required": ["label", "value"],
                                                    "additionalProperties": false
                                                  }
                                                }
                                              },
                                              "required": ["title"],
                                              "additionalProperties": false
                                            }
                                          },
                                          "scheduler": {
                                            "type": "object",
                                            "properties": {
                                              "lifecycle": {
                                                "type": "object",
                                                "properties": {
                                                  "requestId": {
                                                    "type": "string"
                                                  },
                                                  "state": {
                                                    "type": "string",
                                                    "enum": [
                                                      "available",
                                                      "pending",
                                                      "booked",
                                                      "expired",
                                                      "superseded"
                                                    ]
                                                  },
                                                  "expiresAt": {
                                                    "type": "string",
                                                    "format": "date-time",
                                                    "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
                                                  },
                                                  "bookingOperationId": {
                                                    "type": "string"
                                                  }
                                                },
                                                "required": ["requestId", "state", "expiresAt"],
                                                "additionalProperties": false
                                              },
                                              "organizerName": {
                                                "type": "string"
                                              },
                                              "durations": {
                                                "type": "array",
                                                "items": {
                                                  "type": "number"
                                                }
                                              },
                                              "selectedDuration": {
                                                "type": "number"
                                              },
                                              "timezoneLabel": {
                                                "type": "string"
                                              },
                                              "knownName": {
                                                "type": "string"
                                              },
                                              "knownEmail": {
                                                "type": "string"
                                              },
                                              "daysByDuration": {
                                                "type": "object",
                                                "propertyNames": {
                                                  "type": "string"
                                                },
                                                "additionalProperties": {
                                                  "type": "array",
                                                  "items": {
                                                    "type": "object",
                                                    "properties": {
                                                      "date": {
                                                        "type": "string"
                                                      },
                                                      "weekday": {
                                                        "type": "string"
                                                      },
                                                      "dayNum": {
                                                        "type": "string"
                                                      },
                                                      "slots": {
                                                        "type": "array",
                                                        "items": {
                                                          "type": "object",
                                                          "properties": {
                                                            "iso": {
                                                              "type": "string"
                                                            },
                                                            "label": {
                                                              "type": "string"
                                                            }
                                                          },
                                                          "required": ["iso", "label"],
                                                          "additionalProperties": false
                                                        }
                                                      }
                                                    },
                                                    "required": [
                                                      "date",
                                                      "weekday",
                                                      "dayNum",
                                                      "slots"
                                                    ],
                                                    "additionalProperties": false
                                                  }
                                                }
                                              }
                                            },
                                            "required": [
                                              "durations",
                                              "selectedDuration",
                                              "timezoneLabel",
                                              "daysByDuration"
                                            ],
                                            "additionalProperties": false
                                          },
                                          "fileRequest": {
                                            "type": "object",
                                            "properties": {
                                              "prompt": {
                                                "type": "string"
                                              },
                                              "uploadToken": {
                                                "type": "string"
                                              }
                                            },
                                            "required": ["prompt", "uploadToken"],
                                            "additionalProperties": false
                                          }
                                        },
                                        "additionalProperties": false
                                      },
                                      "error": {
                                        "type": "string"
                                      },
                                      "emailDecision": {
                                        "type": "object",
                                        "properties": {
                                          "action": {
                                            "type": "string",
                                            "enum": ["reply", "draft", "ignore", "escalate"]
                                          },
                                          "reason": {
                                            "type": "string"
                                          },
                                          "confidence": {
                                            "type": "number"
                                          },
                                          "guardrailHits": {
                                            "type": "array",
                                            "items": {
                                              "type": "string"
                                            }
                                          }
                                        },
                                        "required": ["action"],
                                        "additionalProperties": false
                                      },
                                      "voice": {
                                        "type": "object",
                                        "properties": {
                                          "voiceCallId": {
                                            "type": "string"
                                          },
                                          "elevenLabsConversationId": {
                                            "type": "string"
                                          },
                                          "timeInCallSecs": {
                                            "type": "number"
                                          }
                                        },
                                        "additionalProperties": false
                                      },
                                      "capabilities": {
                                        "type": "object",
                                        "properties": {
                                          "clientTools": {
                                            "type": "integer",
                                            "minimum": 0,
                                            "maximum": 9007199254740991
                                          },
                                          "workflow": {
                                            "type": "boolean"
                                          },
                                          "adapter": {
                                            "type": "boolean"
                                          },
                                          "internet": {
                                            "type": "boolean"
                                          }
                                        },
                                        "required": [
                                          "clientTools",
                                          "workflow",
                                          "adapter",
                                          "internet"
                                        ],
                                        "additionalProperties": false
                                      },
                                      "handoffOffer": {
                                        "type": "object",
                                        "properties": {
                                          "id": {
                                            "type": "string"
                                          },
                                          "kind": {
                                            "type": "string",
                                            "enum": ["human_support", "human_follow_up"]
                                          },
                                          "status": {
                                            "type": "string",
                                            "enum": [
                                              "pending",
                                              "accepted",
                                              "declined",
                                              "superseded"
                                            ]
                                          },
                                          "language": {
                                            "type": "string",
                                            "enum": ["en", "es", "fr", "de", "pt", "it"]
                                          },
                                          "expiresAt": {
                                            "type": "string"
                                          },
                                          "resolvedByMessageId": {
                                            "type": "string"
                                          }
                                        },
                                        "required": ["id", "kind", "status", "expiresAt"],
                                        "additionalProperties": false
                                      }
                                    },
                                    "additionalProperties": false
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "externalIds": {
                            "anyOf": [
                              {
                                "default": null,
                                "anyOf": [
                                  {
                                    "type": "object",
                                    "propertyNames": {
                                      "type": "string"
                                    },
                                    "additionalProperties": {
                                      "type": "string"
                                    }
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "createdAt": {
                            "type": "string"
                          },
                          "updatedAt": {
                            "type": "string"
                          },
                          "deletedAt": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "aiGenerated": {
                            "type": "boolean",
                            "description": "True when the message was written by the AI agent, false otherwise."
                          }
                        },
                        "required": [
                          "id",
                          "conversationId",
                          "role",
                          "senderId",
                          "senderName",
                          "content",
                          "contentType",
                          "attachments",
                          "status",
                          "statusUpdatedAt",
                          "aiMetadata",
                          "externalIds",
                          "createdAt",
                          "updatedAt",
                          "deletedAt",
                          "aiGenerated"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "hasMore": {
                      "type": "boolean"
                    },
                    "nextCursor": {
                      "type": "string"
                    },
                    "prevCursor": {
                      "type": "string"
                    }
                  },
                  "required": ["messages", "hasMore"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "messages-create",
        "summary": "Create a new message",
        "tags": ["Messages"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "conversationId": {
                    "type": "string"
                  },
                  "role": {
                    "type": "string",
                    "enum": ["contact", "ai", "agent", "system"]
                  },
                  "content": {
                    "type": "string",
                    "minLength": 1
                  },
                  "contentType": {
                    "type": "string",
                    "enum": ["text", "attachment", "system", "html"]
                  },
                  "attachments": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "type": {
                          "type": "string",
                          "enum": ["image", "audio", "video", "file"]
                        },
                        "name": {
                          "type": "string"
                        },
                        "mimeType": {
                          "type": "string"
                        },
                        "size": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "url": {
                          "type": "string",
                          "minLength": 1
                        }
                      },
                      "required": ["id", "type", "name", "mimeType", "size", "url"]
                    }
                  },
                  "externalIds": {
                    "type": "object",
                    "propertyNames": {
                      "type": "string"
                    },
                    "additionalProperties": {
                      "type": "string"
                    }
                  },
                  "senderId": {
                    "type": "string"
                  },
                  "senderName": {
                    "type": "string"
                  },
                  "aiMetadata": {
                    "type": "object",
                    "properties": {
                      "deliveryRevision": {
                        "type": "integer",
                        "exclusiveMinimum": 0,
                        "maximum": 9007199254740991
                      },
                      "model": {
                        "type": "string"
                      },
                      "provider": {
                        "type": "string",
                        "enum": [
                          "openai",
                          "anthropic",
                          "bedrock",
                          "perplexity",
                          "google",
                          "builtin"
                        ]
                      },
                      "toolCalls": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string"
                            },
                            "name": {
                              "type": "string"
                            },
                            "arguments": {
                              "type": "object",
                              "propertyNames": {
                                "type": "string"
                              },
                              "additionalProperties": {}
                            },
                            "result": {},
                            "status": {
                              "type": "string",
                              "enum": ["pending", "completed", "failed"]
                            },
                            "error": {
                              "type": "string"
                            },
                            "durationMs": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991
                            }
                          },
                          "required": ["id", "name", "arguments", "status"]
                        }
                      },
                      "usage": {
                        "type": "object",
                        "properties": {
                          "inputTokens": {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991
                          },
                          "outputTokens": {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991
                          },
                          "prompt": {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991
                          },
                          "completion": {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991
                          },
                          "total": {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991
                          }
                        },
                        "required": ["inputTokens", "outputTokens"]
                      },
                      "latencyMs": {
                        "type": "integer",
                        "minimum": -9007199254740991,
                        "maximum": 9007199254740991
                      },
                      "components": {
                        "type": "object",
                        "properties": {
                          "quickReplies": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "label": {
                                  "type": "string"
                                },
                                "value": {
                                  "type": "string"
                                }
                              },
                              "required": ["label", "value"]
                            }
                          },
                          "card": {
                            "type": "object",
                            "properties": {
                              "title": {
                                "type": "string"
                              },
                              "subtitle": {
                                "type": "string"
                              },
                              "fields": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "label": {
                                      "type": "string"
                                    },
                                    "value": {
                                      "type": "string"
                                    }
                                  },
                                  "required": ["label", "value"]
                                }
                              }
                            },
                            "required": ["title"]
                          },
                          "cards": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "title": {
                                  "type": "string"
                                },
                                "subtitle": {
                                  "type": "string"
                                },
                                "fields": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "label": {
                                        "type": "string"
                                      },
                                      "value": {
                                        "type": "string"
                                      }
                                    },
                                    "required": ["label", "value"]
                                  }
                                }
                              },
                              "required": ["title"]
                            }
                          },
                          "scheduler": {
                            "type": "object",
                            "properties": {
                              "lifecycle": {
                                "type": "object",
                                "properties": {
                                  "requestId": {
                                    "type": "string"
                                  },
                                  "state": {
                                    "type": "string",
                                    "enum": [
                                      "available",
                                      "pending",
                                      "booked",
                                      "expired",
                                      "superseded"
                                    ]
                                  },
                                  "expiresAt": {
                                    "type": "string",
                                    "format": "date-time",
                                    "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
                                  },
                                  "bookingOperationId": {
                                    "type": "string"
                                  }
                                },
                                "required": ["requestId", "state", "expiresAt"]
                              },
                              "organizerName": {
                                "type": "string"
                              },
                              "durations": {
                                "type": "array",
                                "items": {
                                  "type": "number"
                                }
                              },
                              "selectedDuration": {
                                "type": "number"
                              },
                              "timezoneLabel": {
                                "type": "string"
                              },
                              "knownName": {
                                "type": "string"
                              },
                              "knownEmail": {
                                "type": "string"
                              },
                              "daysByDuration": {
                                "type": "object",
                                "propertyNames": {
                                  "type": "string"
                                },
                                "additionalProperties": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "date": {
                                        "type": "string"
                                      },
                                      "weekday": {
                                        "type": "string"
                                      },
                                      "dayNum": {
                                        "type": "string"
                                      },
                                      "slots": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "iso": {
                                              "type": "string"
                                            },
                                            "label": {
                                              "type": "string"
                                            }
                                          },
                                          "required": ["iso", "label"]
                                        }
                                      }
                                    },
                                    "required": ["date", "weekday", "dayNum", "slots"]
                                  }
                                }
                              }
                            },
                            "required": [
                              "durations",
                              "selectedDuration",
                              "timezoneLabel",
                              "daysByDuration"
                            ]
                          },
                          "fileRequest": {
                            "type": "object",
                            "properties": {
                              "prompt": {
                                "type": "string"
                              },
                              "uploadToken": {
                                "type": "string"
                              }
                            },
                            "required": ["prompt", "uploadToken"]
                          }
                        }
                      },
                      "error": {
                        "type": "string"
                      },
                      "emailDecision": {
                        "type": "object",
                        "properties": {
                          "action": {
                            "type": "string",
                            "enum": ["reply", "draft", "ignore", "escalate"]
                          },
                          "reason": {
                            "type": "string"
                          },
                          "confidence": {
                            "type": "number"
                          },
                          "guardrailHits": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          }
                        },
                        "required": ["action"]
                      },
                      "voice": {
                        "type": "object",
                        "properties": {
                          "voiceCallId": {
                            "type": "string"
                          },
                          "elevenLabsConversationId": {
                            "type": "string"
                          },
                          "timeInCallSecs": {
                            "type": "number"
                          }
                        }
                      },
                      "capabilities": {
                        "type": "object",
                        "properties": {
                          "clientTools": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 9007199254740991
                          },
                          "workflow": {
                            "type": "boolean"
                          },
                          "adapter": {
                            "type": "boolean"
                          },
                          "internet": {
                            "type": "boolean"
                          }
                        },
                        "required": ["clientTools", "workflow", "adapter", "internet"]
                      },
                      "handoffOffer": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "kind": {
                            "type": "string",
                            "enum": ["human_support", "human_follow_up"]
                          },
                          "status": {
                            "type": "string",
                            "enum": ["pending", "accepted", "declined", "superseded"]
                          },
                          "language": {
                            "type": "string",
                            "enum": ["en", "es", "fr", "de", "pt", "it"]
                          },
                          "expiresAt": {
                            "type": "string"
                          },
                          "resolvedByMessageId": {
                            "type": "string"
                          }
                        },
                        "required": ["id", "kind", "status", "expiresAt"]
                      }
                    }
                  }
                },
                "required": ["orgId", "conversationId", "role", "content"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "conversationId": {
                      "type": "string"
                    },
                    "role": {
                      "type": "string",
                      "enum": ["contact", "ai", "agent", "system"]
                    },
                    "senderId": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "senderName": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "content": {
                      "type": "string"
                    },
                    "contentType": {
                      "type": "string"
                    },
                    "attachments": {
                      "anyOf": [
                        {
                          "default": null,
                          "anyOf": [
                            {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string"
                                  },
                                  "type": {
                                    "type": "string",
                                    "enum": ["image", "audio", "video", "file"]
                                  },
                                  "name": {
                                    "type": "string"
                                  },
                                  "mimeType": {
                                    "type": "string"
                                  },
                                  "size": {
                                    "type": "integer",
                                    "minimum": -9007199254740991,
                                    "maximum": 9007199254740991
                                  },
                                  "url": {
                                    "type": "string",
                                    "minLength": 1
                                  }
                                },
                                "required": ["id", "type", "name", "mimeType", "size", "url"],
                                "additionalProperties": false
                              }
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "status": {
                      "type": "string",
                      "enum": ["pending", "sent", "delivered", "read", "failed", "draft"]
                    },
                    "statusUpdatedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "aiMetadata": {
                      "anyOf": [
                        {
                          "default": null,
                          "anyOf": [
                            {
                              "type": "object",
                              "properties": {
                                "deliveryRevision": {
                                  "type": "integer",
                                  "exclusiveMinimum": 0,
                                  "maximum": 9007199254740991
                                },
                                "model": {
                                  "type": "string"
                                },
                                "provider": {
                                  "type": "string",
                                  "enum": [
                                    "openai",
                                    "anthropic",
                                    "bedrock",
                                    "perplexity",
                                    "google",
                                    "builtin"
                                  ]
                                },
                                "toolCalls": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "id": {
                                        "type": "string"
                                      },
                                      "name": {
                                        "type": "string"
                                      },
                                      "arguments": {
                                        "type": "object",
                                        "propertyNames": {
                                          "type": "string"
                                        },
                                        "additionalProperties": {}
                                      },
                                      "result": {},
                                      "status": {
                                        "type": "string",
                                        "enum": ["pending", "completed", "failed"]
                                      },
                                      "error": {
                                        "type": "string"
                                      },
                                      "durationMs": {
                                        "type": "integer",
                                        "minimum": -9007199254740991,
                                        "maximum": 9007199254740991
                                      }
                                    },
                                    "required": ["id", "name", "arguments", "status"],
                                    "additionalProperties": false
                                  }
                                },
                                "usage": {
                                  "type": "object",
                                  "properties": {
                                    "inputTokens": {
                                      "type": "integer",
                                      "minimum": -9007199254740991,
                                      "maximum": 9007199254740991
                                    },
                                    "outputTokens": {
                                      "type": "integer",
                                      "minimum": -9007199254740991,
                                      "maximum": 9007199254740991
                                    },
                                    "prompt": {
                                      "type": "integer",
                                      "minimum": -9007199254740991,
                                      "maximum": 9007199254740991
                                    },
                                    "completion": {
                                      "type": "integer",
                                      "minimum": -9007199254740991,
                                      "maximum": 9007199254740991
                                    },
                                    "total": {
                                      "type": "integer",
                                      "minimum": -9007199254740991,
                                      "maximum": 9007199254740991
                                    }
                                  },
                                  "required": ["inputTokens", "outputTokens"],
                                  "additionalProperties": false
                                },
                                "latencyMs": {
                                  "type": "integer",
                                  "minimum": -9007199254740991,
                                  "maximum": 9007199254740991
                                },
                                "components": {
                                  "type": "object",
                                  "properties": {
                                    "quickReplies": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "properties": {
                                          "label": {
                                            "type": "string"
                                          },
                                          "value": {
                                            "type": "string"
                                          }
                                        },
                                        "required": ["label", "value"],
                                        "additionalProperties": false
                                      }
                                    },
                                    "card": {
                                      "type": "object",
                                      "properties": {
                                        "title": {
                                          "type": "string"
                                        },
                                        "subtitle": {
                                          "type": "string"
                                        },
                                        "fields": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "properties": {
                                              "label": {
                                                "type": "string"
                                              },
                                              "value": {
                                                "type": "string"
                                              }
                                            },
                                            "required": ["label", "value"],
                                            "additionalProperties": false
                                          }
                                        }
                                      },
                                      "required": ["title"],
                                      "additionalProperties": false
                                    },
                                    "cards": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "properties": {
                                          "title": {
                                            "type": "string"
                                          },
                                          "subtitle": {
                                            "type": "string"
                                          },
                                          "fields": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "label": {
                                                  "type": "string"
                                                },
                                                "value": {
                                                  "type": "string"
                                                }
                                              },
                                              "required": ["label", "value"],
                                              "additionalProperties": false
                                            }
                                          }
                                        },
                                        "required": ["title"],
                                        "additionalProperties": false
                                      }
                                    },
                                    "scheduler": {
                                      "type": "object",
                                      "properties": {
                                        "lifecycle": {
                                          "type": "object",
                                          "properties": {
                                            "requestId": {
                                              "type": "string"
                                            },
                                            "state": {
                                              "type": "string",
                                              "enum": [
                                                "available",
                                                "pending",
                                                "booked",
                                                "expired",
                                                "superseded"
                                              ]
                                            },
                                            "expiresAt": {
                                              "type": "string",
                                              "format": "date-time",
                                              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
                                            },
                                            "bookingOperationId": {
                                              "type": "string"
                                            }
                                          },
                                          "required": ["requestId", "state", "expiresAt"],
                                          "additionalProperties": false
                                        },
                                        "organizerName": {
                                          "type": "string"
                                        },
                                        "durations": {
                                          "type": "array",
                                          "items": {
                                            "type": "number"
                                          }
                                        },
                                        "selectedDuration": {
                                          "type": "number"
                                        },
                                        "timezoneLabel": {
                                          "type": "string"
                                        },
                                        "knownName": {
                                          "type": "string"
                                        },
                                        "knownEmail": {
                                          "type": "string"
                                        },
                                        "daysByDuration": {
                                          "type": "object",
                                          "propertyNames": {
                                            "type": "string"
                                          },
                                          "additionalProperties": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "date": {
                                                  "type": "string"
                                                },
                                                "weekday": {
                                                  "type": "string"
                                                },
                                                "dayNum": {
                                                  "type": "string"
                                                },
                                                "slots": {
                                                  "type": "array",
                                                  "items": {
                                                    "type": "object",
                                                    "properties": {
                                                      "iso": {
                                                        "type": "string"
                                                      },
                                                      "label": {
                                                        "type": "string"
                                                      }
                                                    },
                                                    "required": ["iso", "label"],
                                                    "additionalProperties": false
                                                  }
                                                }
                                              },
                                              "required": ["date", "weekday", "dayNum", "slots"],
                                              "additionalProperties": false
                                            }
                                          }
                                        }
                                      },
                                      "required": [
                                        "durations",
                                        "selectedDuration",
                                        "timezoneLabel",
                                        "daysByDuration"
                                      ],
                                      "additionalProperties": false
                                    },
                                    "fileRequest": {
                                      "type": "object",
                                      "properties": {
                                        "prompt": {
                                          "type": "string"
                                        },
                                        "uploadToken": {
                                          "type": "string"
                                        }
                                      },
                                      "required": ["prompt", "uploadToken"],
                                      "additionalProperties": false
                                    }
                                  },
                                  "additionalProperties": false
                                },
                                "error": {
                                  "type": "string"
                                },
                                "emailDecision": {
                                  "type": "object",
                                  "properties": {
                                    "action": {
                                      "type": "string",
                                      "enum": ["reply", "draft", "ignore", "escalate"]
                                    },
                                    "reason": {
                                      "type": "string"
                                    },
                                    "confidence": {
                                      "type": "number"
                                    },
                                    "guardrailHits": {
                                      "type": "array",
                                      "items": {
                                        "type": "string"
                                      }
                                    }
                                  },
                                  "required": ["action"],
                                  "additionalProperties": false
                                },
                                "voice": {
                                  "type": "object",
                                  "properties": {
                                    "voiceCallId": {
                                      "type": "string"
                                    },
                                    "elevenLabsConversationId": {
                                      "type": "string"
                                    },
                                    "timeInCallSecs": {
                                      "type": "number"
                                    }
                                  },
                                  "additionalProperties": false
                                },
                                "capabilities": {
                                  "type": "object",
                                  "properties": {
                                    "clientTools": {
                                      "type": "integer",
                                      "minimum": 0,
                                      "maximum": 9007199254740991
                                    },
                                    "workflow": {
                                      "type": "boolean"
                                    },
                                    "adapter": {
                                      "type": "boolean"
                                    },
                                    "internet": {
                                      "type": "boolean"
                                    }
                                  },
                                  "required": ["clientTools", "workflow", "adapter", "internet"],
                                  "additionalProperties": false
                                },
                                "handoffOffer": {
                                  "type": "object",
                                  "properties": {
                                    "id": {
                                      "type": "string"
                                    },
                                    "kind": {
                                      "type": "string",
                                      "enum": ["human_support", "human_follow_up"]
                                    },
                                    "status": {
                                      "type": "string",
                                      "enum": ["pending", "accepted", "declined", "superseded"]
                                    },
                                    "language": {
                                      "type": "string",
                                      "enum": ["en", "es", "fr", "de", "pt", "it"]
                                    },
                                    "expiresAt": {
                                      "type": "string"
                                    },
                                    "resolvedByMessageId": {
                                      "type": "string"
                                    }
                                  },
                                  "required": ["id", "kind", "status", "expiresAt"],
                                  "additionalProperties": false
                                }
                              },
                              "additionalProperties": false
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "externalIds": {
                      "anyOf": [
                        {
                          "default": null,
                          "anyOf": [
                            {
                              "type": "object",
                              "propertyNames": {
                                "type": "string"
                              },
                              "additionalProperties": {
                                "type": "string"
                              }
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "createdAt": {
                      "type": "string"
                    },
                    "updatedAt": {
                      "type": "string"
                    },
                    "deletedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "aiGenerated": {
                      "type": "boolean",
                      "description": "True when the message was written by the AI agent, false otherwise."
                    }
                  },
                  "required": [
                    "id",
                    "conversationId",
                    "role",
                    "senderId",
                    "senderName",
                    "content",
                    "contentType",
                    "attachments",
                    "status",
                    "statusUpdatedAt",
                    "aiMetadata",
                    "externalIds",
                    "createdAt",
                    "updatedAt",
                    "deletedAt",
                    "aiGenerated"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/messages/{id}": {
      "get": {
        "operationId": "messages-get",
        "summary": "Get message by ID",
        "tags": ["Messages"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "conversationId": {
                      "type": "string"
                    },
                    "role": {
                      "type": "string",
                      "enum": ["contact", "ai", "agent", "system"]
                    },
                    "senderId": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "senderName": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "content": {
                      "type": "string"
                    },
                    "contentType": {
                      "type": "string"
                    },
                    "attachments": {
                      "anyOf": [
                        {
                          "default": null,
                          "anyOf": [
                            {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string"
                                  },
                                  "type": {
                                    "type": "string",
                                    "enum": ["image", "audio", "video", "file"]
                                  },
                                  "name": {
                                    "type": "string"
                                  },
                                  "mimeType": {
                                    "type": "string"
                                  },
                                  "size": {
                                    "type": "integer",
                                    "minimum": -9007199254740991,
                                    "maximum": 9007199254740991
                                  },
                                  "url": {
                                    "type": "string",
                                    "minLength": 1
                                  }
                                },
                                "required": ["id", "type", "name", "mimeType", "size", "url"],
                                "additionalProperties": false
                              }
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "status": {
                      "type": "string",
                      "enum": ["pending", "sent", "delivered", "read", "failed", "draft"]
                    },
                    "statusUpdatedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "aiMetadata": {
                      "anyOf": [
                        {
                          "default": null,
                          "anyOf": [
                            {
                              "type": "object",
                              "properties": {
                                "deliveryRevision": {
                                  "type": "integer",
                                  "exclusiveMinimum": 0,
                                  "maximum": 9007199254740991
                                },
                                "model": {
                                  "type": "string"
                                },
                                "provider": {
                                  "type": "string",
                                  "enum": [
                                    "openai",
                                    "anthropic",
                                    "bedrock",
                                    "perplexity",
                                    "google",
                                    "builtin"
                                  ]
                                },
                                "toolCalls": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "id": {
                                        "type": "string"
                                      },
                                      "name": {
                                        "type": "string"
                                      },
                                      "arguments": {
                                        "type": "object",
                                        "propertyNames": {
                                          "type": "string"
                                        },
                                        "additionalProperties": {}
                                      },
                                      "result": {},
                                      "status": {
                                        "type": "string",
                                        "enum": ["pending", "completed", "failed"]
                                      },
                                      "error": {
                                        "type": "string"
                                      },
                                      "durationMs": {
                                        "type": "integer",
                                        "minimum": -9007199254740991,
                                        "maximum": 9007199254740991
                                      }
                                    },
                                    "required": ["id", "name", "arguments", "status"],
                                    "additionalProperties": false
                                  }
                                },
                                "usage": {
                                  "type": "object",
                                  "properties": {
                                    "inputTokens": {
                                      "type": "integer",
                                      "minimum": -9007199254740991,
                                      "maximum": 9007199254740991
                                    },
                                    "outputTokens": {
                                      "type": "integer",
                                      "minimum": -9007199254740991,
                                      "maximum": 9007199254740991
                                    },
                                    "prompt": {
                                      "type": "integer",
                                      "minimum": -9007199254740991,
                                      "maximum": 9007199254740991
                                    },
                                    "completion": {
                                      "type": "integer",
                                      "minimum": -9007199254740991,
                                      "maximum": 9007199254740991
                                    },
                                    "total": {
                                      "type": "integer",
                                      "minimum": -9007199254740991,
                                      "maximum": 9007199254740991
                                    }
                                  },
                                  "required": ["inputTokens", "outputTokens"],
                                  "additionalProperties": false
                                },
                                "latencyMs": {
                                  "type": "integer",
                                  "minimum": -9007199254740991,
                                  "maximum": 9007199254740991
                                },
                                "components": {
                                  "type": "object",
                                  "properties": {
                                    "quickReplies": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "properties": {
                                          "label": {
                                            "type": "string"
                                          },
                                          "value": {
                                            "type": "string"
                                          }
                                        },
                                        "required": ["label", "value"],
                                        "additionalProperties": false
                                      }
                                    },
                                    "card": {
                                      "type": "object",
                                      "properties": {
                                        "title": {
                                          "type": "string"
                                        },
                                        "subtitle": {
                                          "type": "string"
                                        },
                                        "fields": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "properties": {
                                              "label": {
                                                "type": "string"
                                              },
                                              "value": {
                                                "type": "string"
                                              }
                                            },
                                            "required": ["label", "value"],
                                            "additionalProperties": false
                                          }
                                        }
                                      },
                                      "required": ["title"],
                                      "additionalProperties": false
                                    },
                                    "cards": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "properties": {
                                          "title": {
                                            "type": "string"
                                          },
                                          "subtitle": {
                                            "type": "string"
                                          },
                                          "fields": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "label": {
                                                  "type": "string"
                                                },
                                                "value": {
                                                  "type": "string"
                                                }
                                              },
                                              "required": ["label", "value"],
                                              "additionalProperties": false
                                            }
                                          }
                                        },
                                        "required": ["title"],
                                        "additionalProperties": false
                                      }
                                    },
                                    "scheduler": {
                                      "type": "object",
                                      "properties": {
                                        "lifecycle": {
                                          "type": "object",
                                          "properties": {
                                            "requestId": {
                                              "type": "string"
                                            },
                                            "state": {
                                              "type": "string",
                                              "enum": [
                                                "available",
                                                "pending",
                                                "booked",
                                                "expired",
                                                "superseded"
                                              ]
                                            },
                                            "expiresAt": {
                                              "type": "string",
                                              "format": "date-time",
                                              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
                                            },
                                            "bookingOperationId": {
                                              "type": "string"
                                            }
                                          },
                                          "required": ["requestId", "state", "expiresAt"],
                                          "additionalProperties": false
                                        },
                                        "organizerName": {
                                          "type": "string"
                                        },
                                        "durations": {
                                          "type": "array",
                                          "items": {
                                            "type": "number"
                                          }
                                        },
                                        "selectedDuration": {
                                          "type": "number"
                                        },
                                        "timezoneLabel": {
                                          "type": "string"
                                        },
                                        "knownName": {
                                          "type": "string"
                                        },
                                        "knownEmail": {
                                          "type": "string"
                                        },
                                        "daysByDuration": {
                                          "type": "object",
                                          "propertyNames": {
                                            "type": "string"
                                          },
                                          "additionalProperties": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "date": {
                                                  "type": "string"
                                                },
                                                "weekday": {
                                                  "type": "string"
                                                },
                                                "dayNum": {
                                                  "type": "string"
                                                },
                                                "slots": {
                                                  "type": "array",
                                                  "items": {
                                                    "type": "object",
                                                    "properties": {
                                                      "iso": {
                                                        "type": "string"
                                                      },
                                                      "label": {
                                                        "type": "string"
                                                      }
                                                    },
                                                    "required": ["iso", "label"],
                                                    "additionalProperties": false
                                                  }
                                                }
                                              },
                                              "required": ["date", "weekday", "dayNum", "slots"],
                                              "additionalProperties": false
                                            }
                                          }
                                        }
                                      },
                                      "required": [
                                        "durations",
                                        "selectedDuration",
                                        "timezoneLabel",
                                        "daysByDuration"
                                      ],
                                      "additionalProperties": false
                                    },
                                    "fileRequest": {
                                      "type": "object",
                                      "properties": {
                                        "prompt": {
                                          "type": "string"
                                        },
                                        "uploadToken": {
                                          "type": "string"
                                        }
                                      },
                                      "required": ["prompt", "uploadToken"],
                                      "additionalProperties": false
                                    }
                                  },
                                  "additionalProperties": false
                                },
                                "error": {
                                  "type": "string"
                                },
                                "emailDecision": {
                                  "type": "object",
                                  "properties": {
                                    "action": {
                                      "type": "string",
                                      "enum": ["reply", "draft", "ignore", "escalate"]
                                    },
                                    "reason": {
                                      "type": "string"
                                    },
                                    "confidence": {
                                      "type": "number"
                                    },
                                    "guardrailHits": {
                                      "type": "array",
                                      "items": {
                                        "type": "string"
                                      }
                                    }
                                  },
                                  "required": ["action"],
                                  "additionalProperties": false
                                },
                                "voice": {
                                  "type": "object",
                                  "properties": {
                                    "voiceCallId": {
                                      "type": "string"
                                    },
                                    "elevenLabsConversationId": {
                                      "type": "string"
                                    },
                                    "timeInCallSecs": {
                                      "type": "number"
                                    }
                                  },
                                  "additionalProperties": false
                                },
                                "capabilities": {
                                  "type": "object",
                                  "properties": {
                                    "clientTools": {
                                      "type": "integer",
                                      "minimum": 0,
                                      "maximum": 9007199254740991
                                    },
                                    "workflow": {
                                      "type": "boolean"
                                    },
                                    "adapter": {
                                      "type": "boolean"
                                    },
                                    "internet": {
                                      "type": "boolean"
                                    }
                                  },
                                  "required": ["clientTools", "workflow", "adapter", "internet"],
                                  "additionalProperties": false
                                },
                                "handoffOffer": {
                                  "type": "object",
                                  "properties": {
                                    "id": {
                                      "type": "string"
                                    },
                                    "kind": {
                                      "type": "string",
                                      "enum": ["human_support", "human_follow_up"]
                                    },
                                    "status": {
                                      "type": "string",
                                      "enum": ["pending", "accepted", "declined", "superseded"]
                                    },
                                    "language": {
                                      "type": "string",
                                      "enum": ["en", "es", "fr", "de", "pt", "it"]
                                    },
                                    "expiresAt": {
                                      "type": "string"
                                    },
                                    "resolvedByMessageId": {
                                      "type": "string"
                                    }
                                  },
                                  "required": ["id", "kind", "status", "expiresAt"],
                                  "additionalProperties": false
                                }
                              },
                              "additionalProperties": false
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "externalIds": {
                      "anyOf": [
                        {
                          "default": null,
                          "anyOf": [
                            {
                              "type": "object",
                              "propertyNames": {
                                "type": "string"
                              },
                              "additionalProperties": {
                                "type": "string"
                              }
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "createdAt": {
                      "type": "string"
                    },
                    "updatedAt": {
                      "type": "string"
                    },
                    "deletedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "aiGenerated": {
                      "type": "boolean",
                      "description": "True when the message was written by the AI agent, false otherwise."
                    }
                  },
                  "required": [
                    "id",
                    "conversationId",
                    "role",
                    "senderId",
                    "senderName",
                    "content",
                    "contentType",
                    "attachments",
                    "status",
                    "statusUpdatedAt",
                    "aiMetadata",
                    "externalIds",
                    "createdAt",
                    "updatedAt",
                    "deletedAt",
                    "aiGenerated"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "messages-delete",
        "summary": "Delete a message",
        "tags": ["Messages"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    }
                  },
                  "required": ["success"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/messages/{id}/status": {
      "patch": {
        "operationId": "messages-updateStatus",
        "summary": "Update message status",
        "tags": ["Messages"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "status": {
                    "type": "string",
                    "enum": ["pending", "sent", "delivered", "read", "failed", "draft"]
                  }
                },
                "required": ["orgId", "status"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "conversationId": {
                      "type": "string"
                    },
                    "role": {
                      "type": "string",
                      "enum": ["contact", "ai", "agent", "system"]
                    },
                    "senderId": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "senderName": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "content": {
                      "type": "string"
                    },
                    "contentType": {
                      "type": "string"
                    },
                    "attachments": {
                      "anyOf": [
                        {
                          "default": null,
                          "anyOf": [
                            {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string"
                                  },
                                  "type": {
                                    "type": "string",
                                    "enum": ["image", "audio", "video", "file"]
                                  },
                                  "name": {
                                    "type": "string"
                                  },
                                  "mimeType": {
                                    "type": "string"
                                  },
                                  "size": {
                                    "type": "integer",
                                    "minimum": -9007199254740991,
                                    "maximum": 9007199254740991
                                  },
                                  "url": {
                                    "type": "string",
                                    "minLength": 1
                                  }
                                },
                                "required": ["id", "type", "name", "mimeType", "size", "url"],
                                "additionalProperties": false
                              }
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "status": {
                      "type": "string",
                      "enum": ["pending", "sent", "delivered", "read", "failed", "draft"]
                    },
                    "statusUpdatedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "aiMetadata": {
                      "anyOf": [
                        {
                          "default": null,
                          "anyOf": [
                            {
                              "type": "object",
                              "properties": {
                                "deliveryRevision": {
                                  "type": "integer",
                                  "exclusiveMinimum": 0,
                                  "maximum": 9007199254740991
                                },
                                "model": {
                                  "type": "string"
                                },
                                "provider": {
                                  "type": "string",
                                  "enum": [
                                    "openai",
                                    "anthropic",
                                    "bedrock",
                                    "perplexity",
                                    "google",
                                    "builtin"
                                  ]
                                },
                                "toolCalls": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "id": {
                                        "type": "string"
                                      },
                                      "name": {
                                        "type": "string"
                                      },
                                      "arguments": {
                                        "type": "object",
                                        "propertyNames": {
                                          "type": "string"
                                        },
                                        "additionalProperties": {}
                                      },
                                      "result": {},
                                      "status": {
                                        "type": "string",
                                        "enum": ["pending", "completed", "failed"]
                                      },
                                      "error": {
                                        "type": "string"
                                      },
                                      "durationMs": {
                                        "type": "integer",
                                        "minimum": -9007199254740991,
                                        "maximum": 9007199254740991
                                      }
                                    },
                                    "required": ["id", "name", "arguments", "status"],
                                    "additionalProperties": false
                                  }
                                },
                                "usage": {
                                  "type": "object",
                                  "properties": {
                                    "inputTokens": {
                                      "type": "integer",
                                      "minimum": -9007199254740991,
                                      "maximum": 9007199254740991
                                    },
                                    "outputTokens": {
                                      "type": "integer",
                                      "minimum": -9007199254740991,
                                      "maximum": 9007199254740991
                                    },
                                    "prompt": {
                                      "type": "integer",
                                      "minimum": -9007199254740991,
                                      "maximum": 9007199254740991
                                    },
                                    "completion": {
                                      "type": "integer",
                                      "minimum": -9007199254740991,
                                      "maximum": 9007199254740991
                                    },
                                    "total": {
                                      "type": "integer",
                                      "minimum": -9007199254740991,
                                      "maximum": 9007199254740991
                                    }
                                  },
                                  "required": ["inputTokens", "outputTokens"],
                                  "additionalProperties": false
                                },
                                "latencyMs": {
                                  "type": "integer",
                                  "minimum": -9007199254740991,
                                  "maximum": 9007199254740991
                                },
                                "components": {
                                  "type": "object",
                                  "properties": {
                                    "quickReplies": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "properties": {
                                          "label": {
                                            "type": "string"
                                          },
                                          "value": {
                                            "type": "string"
                                          }
                                        },
                                        "required": ["label", "value"],
                                        "additionalProperties": false
                                      }
                                    },
                                    "card": {
                                      "type": "object",
                                      "properties": {
                                        "title": {
                                          "type": "string"
                                        },
                                        "subtitle": {
                                          "type": "string"
                                        },
                                        "fields": {
                                          "type": "array",
                                          "items": {
                                            "type": "object",
                                            "properties": {
                                              "label": {
                                                "type": "string"
                                              },
                                              "value": {
                                                "type": "string"
                                              }
                                            },
                                            "required": ["label", "value"],
                                            "additionalProperties": false
                                          }
                                        }
                                      },
                                      "required": ["title"],
                                      "additionalProperties": false
                                    },
                                    "cards": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "properties": {
                                          "title": {
                                            "type": "string"
                                          },
                                          "subtitle": {
                                            "type": "string"
                                          },
                                          "fields": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "label": {
                                                  "type": "string"
                                                },
                                                "value": {
                                                  "type": "string"
                                                }
                                              },
                                              "required": ["label", "value"],
                                              "additionalProperties": false
                                            }
                                          }
                                        },
                                        "required": ["title"],
                                        "additionalProperties": false
                                      }
                                    },
                                    "scheduler": {
                                      "type": "object",
                                      "properties": {
                                        "lifecycle": {
                                          "type": "object",
                                          "properties": {
                                            "requestId": {
                                              "type": "string"
                                            },
                                            "state": {
                                              "type": "string",
                                              "enum": [
                                                "available",
                                                "pending",
                                                "booked",
                                                "expired",
                                                "superseded"
                                              ]
                                            },
                                            "expiresAt": {
                                              "type": "string",
                                              "format": "date-time",
                                              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
                                            },
                                            "bookingOperationId": {
                                              "type": "string"
                                            }
                                          },
                                          "required": ["requestId", "state", "expiresAt"],
                                          "additionalProperties": false
                                        },
                                        "organizerName": {
                                          "type": "string"
                                        },
                                        "durations": {
                                          "type": "array",
                                          "items": {
                                            "type": "number"
                                          }
                                        },
                                        "selectedDuration": {
                                          "type": "number"
                                        },
                                        "timezoneLabel": {
                                          "type": "string"
                                        },
                                        "knownName": {
                                          "type": "string"
                                        },
                                        "knownEmail": {
                                          "type": "string"
                                        },
                                        "daysByDuration": {
                                          "type": "object",
                                          "propertyNames": {
                                            "type": "string"
                                          },
                                          "additionalProperties": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "date": {
                                                  "type": "string"
                                                },
                                                "weekday": {
                                                  "type": "string"
                                                },
                                                "dayNum": {
                                                  "type": "string"
                                                },
                                                "slots": {
                                                  "type": "array",
                                                  "items": {
                                                    "type": "object",
                                                    "properties": {
                                                      "iso": {
                                                        "type": "string"
                                                      },
                                                      "label": {
                                                        "type": "string"
                                                      }
                                                    },
                                                    "required": ["iso", "label"],
                                                    "additionalProperties": false
                                                  }
                                                }
                                              },
                                              "required": ["date", "weekday", "dayNum", "slots"],
                                              "additionalProperties": false
                                            }
                                          }
                                        }
                                      },
                                      "required": [
                                        "durations",
                                        "selectedDuration",
                                        "timezoneLabel",
                                        "daysByDuration"
                                      ],
                                      "additionalProperties": false
                                    },
                                    "fileRequest": {
                                      "type": "object",
                                      "properties": {
                                        "prompt": {
                                          "type": "string"
                                        },
                                        "uploadToken": {
                                          "type": "string"
                                        }
                                      },
                                      "required": ["prompt", "uploadToken"],
                                      "additionalProperties": false
                                    }
                                  },
                                  "additionalProperties": false
                                },
                                "error": {
                                  "type": "string"
                                },
                                "emailDecision": {
                                  "type": "object",
                                  "properties": {
                                    "action": {
                                      "type": "string",
                                      "enum": ["reply", "draft", "ignore", "escalate"]
                                    },
                                    "reason": {
                                      "type": "string"
                                    },
                                    "confidence": {
                                      "type": "number"
                                    },
                                    "guardrailHits": {
                                      "type": "array",
                                      "items": {
                                        "type": "string"
                                      }
                                    }
                                  },
                                  "required": ["action"],
                                  "additionalProperties": false
                                },
                                "voice": {
                                  "type": "object",
                                  "properties": {
                                    "voiceCallId": {
                                      "type": "string"
                                    },
                                    "elevenLabsConversationId": {
                                      "type": "string"
                                    },
                                    "timeInCallSecs": {
                                      "type": "number"
                                    }
                                  },
                                  "additionalProperties": false
                                },
                                "capabilities": {
                                  "type": "object",
                                  "properties": {
                                    "clientTools": {
                                      "type": "integer",
                                      "minimum": 0,
                                      "maximum": 9007199254740991
                                    },
                                    "workflow": {
                                      "type": "boolean"
                                    },
                                    "adapter": {
                                      "type": "boolean"
                                    },
                                    "internet": {
                                      "type": "boolean"
                                    }
                                  },
                                  "required": ["clientTools", "workflow", "adapter", "internet"],
                                  "additionalProperties": false
                                },
                                "handoffOffer": {
                                  "type": "object",
                                  "properties": {
                                    "id": {
                                      "type": "string"
                                    },
                                    "kind": {
                                      "type": "string",
                                      "enum": ["human_support", "human_follow_up"]
                                    },
                                    "status": {
                                      "type": "string",
                                      "enum": ["pending", "accepted", "declined", "superseded"]
                                    },
                                    "language": {
                                      "type": "string",
                                      "enum": ["en", "es", "fr", "de", "pt", "it"]
                                    },
                                    "expiresAt": {
                                      "type": "string"
                                    },
                                    "resolvedByMessageId": {
                                      "type": "string"
                                    }
                                  },
                                  "required": ["id", "kind", "status", "expiresAt"],
                                  "additionalProperties": false
                                }
                              },
                              "additionalProperties": false
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "externalIds": {
                      "anyOf": [
                        {
                          "default": null,
                          "anyOf": [
                            {
                              "type": "object",
                              "propertyNames": {
                                "type": "string"
                              },
                              "additionalProperties": {
                                "type": "string"
                              }
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "createdAt": {
                      "type": "string"
                    },
                    "updatedAt": {
                      "type": "string"
                    },
                    "deletedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "aiGenerated": {
                      "type": "boolean",
                      "description": "True when the message was written by the AI agent, false otherwise."
                    }
                  },
                  "required": [
                    "id",
                    "conversationId",
                    "role",
                    "senderId",
                    "senderName",
                    "content",
                    "contentType",
                    "attachments",
                    "status",
                    "statusUpdatedAt",
                    "aiMetadata",
                    "externalIds",
                    "createdAt",
                    "updatedAt",
                    "deletedAt",
                    "aiGenerated"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/conversations/{conversationId}/read": {
      "post": {
        "operationId": "messages-markRead",
        "summary": "Mark conversation messages as read",
        "tags": ["Messages"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "conversationId",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  }
                },
                "required": ["orgId"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    }
                  },
                  "required": ["success"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/labels": {
      "get": {
        "operationId": "labels-list",
        "summary": "List labels",
        "tags": ["Labels"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "labels": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "orgId": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "color": {
                            "type": "string"
                          },
                          "description": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "createdAt": {
                            "type": "string"
                          },
                          "updatedAt": {
                            "type": "string"
                          },
                          "deletedAt": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        },
                        "required": [
                          "id",
                          "orgId",
                          "name",
                          "color",
                          "description",
                          "createdAt",
                          "updatedAt",
                          "deletedAt"
                        ],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": ["labels"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "labels-create",
        "summary": "Create a new label",
        "tags": ["Labels"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 50
                  },
                  "color": {
                    "type": "string",
                    "pattern": "^#[0-9A-Fa-f]{6}$"
                  },
                  "description": {
                    "type": "string",
                    "maxLength": 200
                  }
                },
                "required": ["orgId", "name", "color"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "orgId": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "color": {
                      "type": "string"
                    },
                    "description": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "createdAt": {
                      "type": "string"
                    },
                    "updatedAt": {
                      "type": "string"
                    },
                    "deletedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": [
                    "id",
                    "orgId",
                    "name",
                    "color",
                    "description",
                    "createdAt",
                    "updatedAt",
                    "deletedAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/labels/{id}": {
      "get": {
        "operationId": "labels-get",
        "summary": "Get label by ID",
        "tags": ["Labels"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "orgId": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "color": {
                      "type": "string"
                    },
                    "description": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "createdAt": {
                      "type": "string"
                    },
                    "updatedAt": {
                      "type": "string"
                    },
                    "deletedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": [
                    "id",
                    "orgId",
                    "name",
                    "color",
                    "description",
                    "createdAt",
                    "updatedAt",
                    "deletedAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "labels-update",
        "summary": "Update a label",
        "tags": ["Labels"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 50
                  },
                  "color": {
                    "type": "string",
                    "pattern": "^#[0-9A-Fa-f]{6}$"
                  },
                  "description": {
                    "type": "string",
                    "maxLength": 200
                  }
                },
                "required": ["orgId"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "orgId": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "color": {
                      "type": "string"
                    },
                    "description": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "createdAt": {
                      "type": "string"
                    },
                    "updatedAt": {
                      "type": "string"
                    },
                    "deletedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": [
                    "id",
                    "orgId",
                    "name",
                    "color",
                    "description",
                    "createdAt",
                    "updatedAt",
                    "deletedAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "labels-delete",
        "summary": "Delete a label",
        "tags": ["Labels"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    }
                  },
                  "required": ["success"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/contact-tags": {
      "get": {
        "operationId": "contactTags-list",
        "summary": "List contact tags",
        "tags": ["Contact tags"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "tags": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "orgId": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "color": {
                            "type": "string"
                          },
                          "createdAt": {
                            "type": "string"
                          },
                          "updatedAt": {
                            "type": "string"
                          },
                          "deletedAt": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        },
                        "required": [
                          "id",
                          "orgId",
                          "name",
                          "color",
                          "createdAt",
                          "updatedAt",
                          "deletedAt"
                        ],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": ["tags"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "contactTags-create",
        "summary": "Create a new contact tag",
        "tags": ["Contact tags"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 48
                  },
                  "color": {
                    "type": "string",
                    "pattern": "^#[0-9A-Fa-f]{6}$"
                  }
                },
                "required": ["orgId", "name"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "orgId": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "color": {
                      "type": "string"
                    },
                    "createdAt": {
                      "type": "string"
                    },
                    "updatedAt": {
                      "type": "string"
                    },
                    "deletedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": [
                    "id",
                    "orgId",
                    "name",
                    "color",
                    "createdAt",
                    "updatedAt",
                    "deletedAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/contact-tags/{id}": {
      "get": {
        "operationId": "contactTags-get",
        "summary": "Get contact tag by ID",
        "tags": ["Contact tags"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "orgId": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "color": {
                      "type": "string"
                    },
                    "createdAt": {
                      "type": "string"
                    },
                    "updatedAt": {
                      "type": "string"
                    },
                    "deletedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": [
                    "id",
                    "orgId",
                    "name",
                    "color",
                    "createdAt",
                    "updatedAt",
                    "deletedAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "contactTags-update",
        "summary": "Update a contact tag",
        "tags": ["Contact tags"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 48
                  },
                  "color": {
                    "type": "string",
                    "pattern": "^#[0-9A-Fa-f]{6}$"
                  }
                },
                "required": ["orgId"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "orgId": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "color": {
                      "type": "string"
                    },
                    "createdAt": {
                      "type": "string"
                    },
                    "updatedAt": {
                      "type": "string"
                    },
                    "deletedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": [
                    "id",
                    "orgId",
                    "name",
                    "color",
                    "createdAt",
                    "updatedAt",
                    "deletedAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "contactTags-delete",
        "summary": "Delete a contact tag",
        "tags": ["Contact tags"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    }
                  },
                  "required": ["success"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/lifecycle-stages": {
      "get": {
        "operationId": "lifecycleStages-list",
        "summary": "List lifecycle stages",
        "tags": ["Lifecycle Stages"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "stages": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "orgId": {
                            "type": "string"
                          },
                          "key": {
                            "type": "string"
                          },
                          "label": {
                            "type": "string"
                          },
                          "color": {
                            "type": "string"
                          },
                          "description": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "position": {
                            "type": "integer",
                            "minimum": -2147483648,
                            "maximum": 2147483647
                          },
                          "isDefault": {
                            "type": "boolean"
                          },
                          "externalIds": {
                            "default": {},
                            "type": "object",
                            "propertyNames": {
                              "type": "string"
                            },
                            "additionalProperties": {
                              "type": "string"
                            }
                          },
                          "createdAt": {
                            "type": "string"
                          },
                          "updatedAt": {
                            "type": "string"
                          },
                          "deletedAt": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        },
                        "required": [
                          "id",
                          "orgId",
                          "key",
                          "label",
                          "color",
                          "description",
                          "position",
                          "isDefault",
                          "externalIds",
                          "createdAt",
                          "updatedAt",
                          "deletedAt"
                        ],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": ["stages"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "lifecycleStages-create",
        "summary": "Create a new lifecycle stage",
        "tags": ["Lifecycle Stages"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "key": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 50,
                    "pattern": "^[a-z][a-z0-9_]*$"
                  },
                  "label": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 50
                  },
                  "color": {
                    "type": "string",
                    "pattern": "^#[0-9A-Fa-f]{6}$"
                  },
                  "description": {
                    "type": "string",
                    "maxLength": 200
                  },
                  "position": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 9007199254740991
                  },
                  "externalIds": {
                    "type": "object",
                    "propertyNames": {
                      "type": "string"
                    },
                    "additionalProperties": {
                      "type": "string"
                    }
                  }
                },
                "required": ["orgId", "key", "label", "color"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "orgId": {
                      "type": "string"
                    },
                    "key": {
                      "type": "string"
                    },
                    "label": {
                      "type": "string"
                    },
                    "color": {
                      "type": "string"
                    },
                    "description": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "position": {
                      "type": "integer",
                      "minimum": -2147483648,
                      "maximum": 2147483647
                    },
                    "isDefault": {
                      "type": "boolean"
                    },
                    "externalIds": {
                      "default": {},
                      "type": "object",
                      "propertyNames": {
                        "type": "string"
                      },
                      "additionalProperties": {
                        "type": "string"
                      }
                    },
                    "createdAt": {
                      "type": "string"
                    },
                    "updatedAt": {
                      "type": "string"
                    },
                    "deletedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": [
                    "id",
                    "orgId",
                    "key",
                    "label",
                    "color",
                    "description",
                    "position",
                    "isDefault",
                    "externalIds",
                    "createdAt",
                    "updatedAt",
                    "deletedAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/lifecycle-stages/{id}": {
      "get": {
        "operationId": "lifecycleStages-get",
        "summary": "Get lifecycle stage by ID",
        "tags": ["Lifecycle Stages"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "orgId": {
                      "type": "string"
                    },
                    "key": {
                      "type": "string"
                    },
                    "label": {
                      "type": "string"
                    },
                    "color": {
                      "type": "string"
                    },
                    "description": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "position": {
                      "type": "integer",
                      "minimum": -2147483648,
                      "maximum": 2147483647
                    },
                    "isDefault": {
                      "type": "boolean"
                    },
                    "externalIds": {
                      "default": {},
                      "type": "object",
                      "propertyNames": {
                        "type": "string"
                      },
                      "additionalProperties": {
                        "type": "string"
                      }
                    },
                    "createdAt": {
                      "type": "string"
                    },
                    "updatedAt": {
                      "type": "string"
                    },
                    "deletedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": [
                    "id",
                    "orgId",
                    "key",
                    "label",
                    "color",
                    "description",
                    "position",
                    "isDefault",
                    "externalIds",
                    "createdAt",
                    "updatedAt",
                    "deletedAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "lifecycleStages-update",
        "summary": "Update a lifecycle stage",
        "tags": ["Lifecycle Stages"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "label": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 50
                  },
                  "color": {
                    "type": "string",
                    "pattern": "^#[0-9A-Fa-f]{6}$"
                  },
                  "description": {
                    "type": "string",
                    "maxLength": 200
                  },
                  "position": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 9007199254740991
                  },
                  "externalIds": {
                    "type": "object",
                    "propertyNames": {
                      "type": "string"
                    },
                    "additionalProperties": {
                      "type": "string"
                    }
                  },
                  "isDefault": {
                    "type": "boolean"
                  }
                },
                "required": ["orgId"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "orgId": {
                      "type": "string"
                    },
                    "key": {
                      "type": "string"
                    },
                    "label": {
                      "type": "string"
                    },
                    "color": {
                      "type": "string"
                    },
                    "description": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "position": {
                      "type": "integer",
                      "minimum": -2147483648,
                      "maximum": 2147483647
                    },
                    "isDefault": {
                      "type": "boolean"
                    },
                    "externalIds": {
                      "default": {},
                      "type": "object",
                      "propertyNames": {
                        "type": "string"
                      },
                      "additionalProperties": {
                        "type": "string"
                      }
                    },
                    "createdAt": {
                      "type": "string"
                    },
                    "updatedAt": {
                      "type": "string"
                    },
                    "deletedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": [
                    "id",
                    "orgId",
                    "key",
                    "label",
                    "color",
                    "description",
                    "position",
                    "isDefault",
                    "externalIds",
                    "createdAt",
                    "updatedAt",
                    "deletedAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "lifecycleStages-delete",
        "summary": "Delete a lifecycle stage",
        "tags": ["Lifecycle Stages"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    }
                  },
                  "required": ["success"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/lifecycle-stages/reorder": {
      "post": {
        "operationId": "lifecycleStages-reorder",
        "summary": "Reorder lifecycle stages",
        "tags": ["Lifecycle Stages"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "stageIds": {
                    "minItems": 1,
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                },
                "required": ["orgId", "stageIds"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    }
                  },
                  "required": ["success"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/notes": {
      "get": {
        "operationId": "notes-list",
        "summary": "List notes for a conversation",
        "tags": ["Notes"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "conversationId",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "notes": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "conversationId": {
                            "type": "string"
                          },
                          "authorId": {
                            "type": "string"
                          },
                          "authorName": {
                            "type": "string"
                          },
                          "content": {
                            "type": "string"
                          },
                          "mentions": {
                            "default": [],
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "userId": {
                                  "type": "string"
                                },
                                "displayName": {
                                  "type": "string"
                                },
                                "startIndex": {
                                  "type": "integer",
                                  "minimum": -9007199254740991,
                                  "maximum": 9007199254740991
                                },
                                "endIndex": {
                                  "type": "integer",
                                  "minimum": -9007199254740991,
                                  "maximum": 9007199254740991
                                }
                              },
                              "required": ["userId", "displayName", "startIndex", "endIndex"],
                              "additionalProperties": false
                            }
                          },
                          "createdAt": {
                            "type": "string"
                          },
                          "updatedAt": {
                            "type": "string"
                          },
                          "deletedAt": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        },
                        "required": [
                          "id",
                          "conversationId",
                          "authorId",
                          "authorName",
                          "content",
                          "mentions",
                          "createdAt",
                          "updatedAt",
                          "deletedAt"
                        ],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": ["notes"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "notes-create",
        "summary": "Create a new note",
        "tags": ["Notes"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "conversationId": {
                    "type": "string"
                  },
                  "content": {
                    "type": "string",
                    "minLength": 1
                  },
                  "mentions": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "userId": {
                          "type": "string"
                        },
                        "displayName": {
                          "type": "string"
                        },
                        "startIndex": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "endIndex": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        }
                      },
                      "required": ["userId", "displayName", "startIndex", "endIndex"]
                    }
                  }
                },
                "required": ["orgId", "conversationId", "content"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "conversationId": {
                      "type": "string"
                    },
                    "authorId": {
                      "type": "string"
                    },
                    "authorName": {
                      "type": "string"
                    },
                    "content": {
                      "type": "string"
                    },
                    "mentions": {
                      "default": [],
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "userId": {
                            "type": "string"
                          },
                          "displayName": {
                            "type": "string"
                          },
                          "startIndex": {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991
                          },
                          "endIndex": {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991
                          }
                        },
                        "required": ["userId", "displayName", "startIndex", "endIndex"],
                        "additionalProperties": false
                      }
                    },
                    "createdAt": {
                      "type": "string"
                    },
                    "updatedAt": {
                      "type": "string"
                    },
                    "deletedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": [
                    "id",
                    "conversationId",
                    "authorId",
                    "authorName",
                    "content",
                    "mentions",
                    "createdAt",
                    "updatedAt",
                    "deletedAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/notes/{id}": {
      "get": {
        "operationId": "notes-get",
        "summary": "Get note by ID",
        "tags": ["Notes"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "conversationId": {
                      "type": "string"
                    },
                    "authorId": {
                      "type": "string"
                    },
                    "authorName": {
                      "type": "string"
                    },
                    "content": {
                      "type": "string"
                    },
                    "mentions": {
                      "default": [],
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "userId": {
                            "type": "string"
                          },
                          "displayName": {
                            "type": "string"
                          },
                          "startIndex": {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991
                          },
                          "endIndex": {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991
                          }
                        },
                        "required": ["userId", "displayName", "startIndex", "endIndex"],
                        "additionalProperties": false
                      }
                    },
                    "createdAt": {
                      "type": "string"
                    },
                    "updatedAt": {
                      "type": "string"
                    },
                    "deletedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": [
                    "id",
                    "conversationId",
                    "authorId",
                    "authorName",
                    "content",
                    "mentions",
                    "createdAt",
                    "updatedAt",
                    "deletedAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "notes-update",
        "summary": "Update a note",
        "tags": ["Notes"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "content": {
                    "type": "string",
                    "minLength": 1
                  },
                  "mentions": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "userId": {
                          "type": "string"
                        },
                        "displayName": {
                          "type": "string"
                        },
                        "startIndex": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "endIndex": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        }
                      },
                      "required": ["userId", "displayName", "startIndex", "endIndex"]
                    }
                  }
                },
                "required": ["orgId", "content"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "conversationId": {
                      "type": "string"
                    },
                    "authorId": {
                      "type": "string"
                    },
                    "authorName": {
                      "type": "string"
                    },
                    "content": {
                      "type": "string"
                    },
                    "mentions": {
                      "default": [],
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "userId": {
                            "type": "string"
                          },
                          "displayName": {
                            "type": "string"
                          },
                          "startIndex": {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991
                          },
                          "endIndex": {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991
                          }
                        },
                        "required": ["userId", "displayName", "startIndex", "endIndex"],
                        "additionalProperties": false
                      }
                    },
                    "createdAt": {
                      "type": "string"
                    },
                    "updatedAt": {
                      "type": "string"
                    },
                    "deletedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": [
                    "id",
                    "conversationId",
                    "authorId",
                    "authorName",
                    "content",
                    "mentions",
                    "createdAt",
                    "updatedAt",
                    "deletedAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "notes-delete",
        "summary": "Delete a note",
        "tags": ["Notes"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    }
                  },
                  "required": ["success"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/escalations": {
      "get": {
        "operationId": "escalations-list",
        "summary": "List escalations",
        "tags": ["Escalations"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "status",
            "schema": {
              "type": "string",
              "enum": [
                "open",
                "in_progress",
                "resolved",
                "learning_pending",
                "learning_approved",
                "dismissed"
              ]
            }
          },
          {
            "in": "query",
            "name": "statuses",
            "schema": {
              "type": "array",
              "items": {
                "type": "string",
                "enum": [
                  "open",
                  "in_progress",
                  "resolved",
                  "learning_pending",
                  "learning_approved",
                  "dismissed"
                ]
              }
            }
          },
          {
            "in": "query",
            "name": "channel",
            "schema": {
              "type": "string",
              "enum": ["voice", "sms", "whatsapp", "chat", "email", "instagram", "google_reviews"]
            }
          },
          {
            "in": "query",
            "name": "assignedTo",
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "limit",
            "schema": {
              "default": 50,
              "type": "integer",
              "minimum": 1,
              "maximum": 100
            }
          },
          {
            "in": "query",
            "name": "offset",
            "schema": {
              "default": 0,
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "escalations": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "orgId": {
                            "type": "string"
                          },
                          "conversationId": {
                            "type": "string"
                          },
                          "triggerMessageId": {
                            "anyOf": [
                              {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "type": {
                            "type": "string",
                            "enum": [
                              "low_confidence",
                              "keyword_triggered",
                              "tool_failure",
                              "repeated_failure",
                              "explicit_request"
                            ]
                          },
                          "channel": {
                            "type": "string",
                            "enum": [
                              "voice",
                              "sms",
                              "whatsapp",
                              "chat",
                              "email",
                              "instagram",
                              "google_reviews"
                            ]
                          },
                          "triggerReason": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "confidenceScore": {
                            "anyOf": [
                              {
                                "type": "number",
                                "minimum": -8388608,
                                "maximum": 8388607
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "customerQuery": {
                            "type": "string"
                          },
                          "conversationSummary": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "aiAttemptedResponse": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "status": {
                            "type": "string",
                            "enum": [
                              "open",
                              "in_progress",
                              "resolved",
                              "learning_pending",
                              "learning_approved",
                              "dismissed"
                            ]
                          },
                          "assignedTo": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "resolvedBy": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "resolvedAt": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "staffResponse": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "staffResponseMessageId": {
                            "anyOf": [
                              {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "extractedQuestion": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "extractedAnswer": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "suggestedTags": {
                            "anyOf": [
                              {
                                "default": [],
                                "type": "array",
                                "items": {
                                  "type": "string"
                                }
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "extractionConfidence": {
                            "anyOf": [
                              {
                                "type": "number",
                                "minimum": -8388608,
                                "maximum": 8388607
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "knowledgeSourceId": {
                            "anyOf": [
                              {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "learningApprovedBy": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "learningApprovedAt": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "timesRetrieved": {
                            "type": "integer",
                            "minimum": -2147483648,
                            "maximum": 2147483647
                          },
                          "helpfulVotes": {
                            "type": "integer",
                            "minimum": -2147483648,
                            "maximum": 2147483647
                          },
                          "notHelpfulVotes": {
                            "type": "integer",
                            "minimum": -2147483648,
                            "maximum": 2147483647
                          },
                          "createdAt": {
                            "type": "string"
                          },
                          "updatedAt": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "id",
                          "orgId",
                          "conversationId",
                          "triggerMessageId",
                          "type",
                          "channel",
                          "triggerReason",
                          "confidenceScore",
                          "customerQuery",
                          "conversationSummary",
                          "aiAttemptedResponse",
                          "status",
                          "assignedTo",
                          "resolvedBy",
                          "resolvedAt",
                          "staffResponse",
                          "staffResponseMessageId",
                          "extractedQuestion",
                          "extractedAnswer",
                          "suggestedTags",
                          "extractionConfidence",
                          "knowledgeSourceId",
                          "learningApprovedBy",
                          "learningApprovedAt",
                          "timesRetrieved",
                          "helpfulVotes",
                          "notHelpfulVotes",
                          "createdAt",
                          "updatedAt"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "pagination": {
                      "type": "object",
                      "properties": {
                        "total": {
                          "type": "number"
                        },
                        "limit": {
                          "type": "number"
                        },
                        "offset": {
                          "type": "number"
                        }
                      },
                      "required": ["total", "limit", "offset"],
                      "additionalProperties": false
                    }
                  },
                  "required": ["escalations", "pagination"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "escalations-create",
        "summary": "Create an escalation",
        "tags": ["Escalations"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "conversationId": {
                    "type": "string"
                  },
                  "triggerMessageId": {
                    "type": "string"
                  },
                  "type": {
                    "type": "string",
                    "enum": [
                      "low_confidence",
                      "keyword_triggered",
                      "tool_failure",
                      "repeated_failure",
                      "explicit_request"
                    ]
                  },
                  "customerQuery": {
                    "type": "string"
                  },
                  "triggerReason": {
                    "type": "string"
                  },
                  "confidenceScore": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 1
                  },
                  "conversationSummary": {
                    "type": "string"
                  },
                  "aiAttemptedResponse": {
                    "type": "string"
                  },
                  "channel": {
                    "type": "string",
                    "enum": [
                      "voice",
                      "sms",
                      "whatsapp",
                      "chat",
                      "email",
                      "instagram",
                      "google_reviews"
                    ]
                  }
                },
                "required": ["orgId", "conversationId", "type", "customerQuery", "channel"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "orgId": {
                      "type": "string"
                    },
                    "conversationId": {
                      "type": "string"
                    },
                    "triggerMessageId": {
                      "anyOf": [
                        {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "type": {
                      "type": "string",
                      "enum": [
                        "low_confidence",
                        "keyword_triggered",
                        "tool_failure",
                        "repeated_failure",
                        "explicit_request"
                      ]
                    },
                    "channel": {
                      "type": "string",
                      "enum": [
                        "voice",
                        "sms",
                        "whatsapp",
                        "chat",
                        "email",
                        "instagram",
                        "google_reviews"
                      ]
                    },
                    "triggerReason": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "confidenceScore": {
                      "anyOf": [
                        {
                          "type": "number",
                          "minimum": -8388608,
                          "maximum": 8388607
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "customerQuery": {
                      "type": "string"
                    },
                    "conversationSummary": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "aiAttemptedResponse": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "open",
                        "in_progress",
                        "resolved",
                        "learning_pending",
                        "learning_approved",
                        "dismissed"
                      ]
                    },
                    "assignedTo": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "resolvedBy": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "resolvedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "staffResponse": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "staffResponseMessageId": {
                      "anyOf": [
                        {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "extractedQuestion": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "extractedAnswer": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "suggestedTags": {
                      "anyOf": [
                        {
                          "default": [],
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "extractionConfidence": {
                      "anyOf": [
                        {
                          "type": "number",
                          "minimum": -8388608,
                          "maximum": 8388607
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "knowledgeSourceId": {
                      "anyOf": [
                        {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "learningApprovedBy": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "learningApprovedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "timesRetrieved": {
                      "type": "integer",
                      "minimum": -2147483648,
                      "maximum": 2147483647
                    },
                    "helpfulVotes": {
                      "type": "integer",
                      "minimum": -2147483648,
                      "maximum": 2147483647
                    },
                    "notHelpfulVotes": {
                      "type": "integer",
                      "minimum": -2147483648,
                      "maximum": 2147483647
                    },
                    "createdAt": {
                      "type": "string"
                    },
                    "updatedAt": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "id",
                    "orgId",
                    "conversationId",
                    "triggerMessageId",
                    "type",
                    "channel",
                    "triggerReason",
                    "confidenceScore",
                    "customerQuery",
                    "conversationSummary",
                    "aiAttemptedResponse",
                    "status",
                    "assignedTo",
                    "resolvedBy",
                    "resolvedAt",
                    "staffResponse",
                    "staffResponseMessageId",
                    "extractedQuestion",
                    "extractedAnswer",
                    "suggestedTags",
                    "extractionConfidence",
                    "knowledgeSourceId",
                    "learningApprovedBy",
                    "learningApprovedAt",
                    "timesRetrieved",
                    "helpfulVotes",
                    "notHelpfulVotes",
                    "createdAt",
                    "updatedAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/escalations/{id}": {
      "get": {
        "operationId": "escalations-get",
        "summary": "Get escalation by ID",
        "tags": ["Escalations"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "orgId": {
                      "type": "string"
                    },
                    "conversationId": {
                      "type": "string"
                    },
                    "triggerMessageId": {
                      "anyOf": [
                        {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "type": {
                      "type": "string",
                      "enum": [
                        "low_confidence",
                        "keyword_triggered",
                        "tool_failure",
                        "repeated_failure",
                        "explicit_request"
                      ]
                    },
                    "channel": {
                      "type": "string",
                      "enum": [
                        "voice",
                        "sms",
                        "whatsapp",
                        "chat",
                        "email",
                        "instagram",
                        "google_reviews"
                      ]
                    },
                    "triggerReason": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "confidenceScore": {
                      "anyOf": [
                        {
                          "type": "number",
                          "minimum": -8388608,
                          "maximum": 8388607
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "customerQuery": {
                      "type": "string"
                    },
                    "conversationSummary": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "aiAttemptedResponse": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "open",
                        "in_progress",
                        "resolved",
                        "learning_pending",
                        "learning_approved",
                        "dismissed"
                      ]
                    },
                    "assignedTo": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "resolvedBy": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "resolvedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "staffResponse": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "staffResponseMessageId": {
                      "anyOf": [
                        {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "extractedQuestion": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "extractedAnswer": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "suggestedTags": {
                      "anyOf": [
                        {
                          "default": [],
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "extractionConfidence": {
                      "anyOf": [
                        {
                          "type": "number",
                          "minimum": -8388608,
                          "maximum": 8388607
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "knowledgeSourceId": {
                      "anyOf": [
                        {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "learningApprovedBy": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "learningApprovedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "timesRetrieved": {
                      "type": "integer",
                      "minimum": -2147483648,
                      "maximum": 2147483647
                    },
                    "helpfulVotes": {
                      "type": "integer",
                      "minimum": -2147483648,
                      "maximum": 2147483647
                    },
                    "notHelpfulVotes": {
                      "type": "integer",
                      "minimum": -2147483648,
                      "maximum": 2147483647
                    },
                    "createdAt": {
                      "type": "string"
                    },
                    "updatedAt": {
                      "type": "string"
                    },
                    "conversation": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "orgId": {
                          "type": "string"
                        },
                        "inboxId": {
                          "type": "string"
                        },
                        "contactId": {
                          "type": "string"
                        },
                        "displayId": {
                          "type": "integer",
                          "minimum": -2147483648,
                          "maximum": 2147483647
                        },
                        "subject": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "status": {
                          "type": "string",
                          "enum": ["open", "pending", "snoozed", "resolved"]
                        },
                        "priority": {
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": ["low", "medium", "high", "urgent"]
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "assigneeType": {
                          "type": "string",
                          "enum": ["ai", "agent", "unassigned"]
                        },
                        "assigneeId": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "channel": {
                          "type": "string",
                          "enum": [
                            "voice",
                            "sms",
                            "whatsapp",
                            "chat",
                            "email",
                            "instagram",
                            "google_reviews"
                          ]
                        },
                        "inbound": {
                          "type": "boolean"
                        },
                        "lastActivityAt": {
                          "type": "string"
                        },
                        "firstResponseAt": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "resolvedAt": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "snoozedUntil": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "outcome": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "outcomeData": {
                          "anyOf": [
                            {
                              "default": null,
                              "anyOf": [
                                {
                                  "type": "object",
                                  "propertyNames": {
                                    "type": "string"
                                  },
                                  "additionalProperties": {}
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "labelIds": {
                          "default": [],
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "externalIds": {
                          "default": {},
                          "type": "object",
                          "propertyNames": {
                            "type": "string"
                          },
                          "additionalProperties": {
                            "type": "string"
                          }
                        },
                        "messageCount": {
                          "type": "integer",
                          "minimum": -2147483648,
                          "maximum": 2147483647
                        },
                        "unreadCount": {
                          "type": "integer",
                          "minimum": -2147483648,
                          "maximum": 2147483647
                        },
                        "autoResolveStage": {
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": ["candidate", "gate", "follow_up", "warning", "grace"]
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "autoResolveCandidateAt": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "autoResolvePaused": {
                          "type": "boolean"
                        },
                        "agentLockUntil": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "channelWindowExpiresAt": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "relatedConversationId": {
                          "anyOf": [
                            {},
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "workflowRunId": {
                          "anyOf": [
                            {},
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "reopenCount": {
                          "type": "integer",
                          "minimum": -2147483648,
                          "maximum": 2147483647
                        },
                        "version": {
                          "type": "integer",
                          "minimum": -2147483648,
                          "maximum": 2147483647
                        },
                        "createdAt": {
                          "type": "string"
                        },
                        "updatedAt": {
                          "type": "string"
                        },
                        "contactLastReadAt": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "agentLastReadAt": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "deletedAt": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      },
                      "required": [
                        "id",
                        "orgId",
                        "inboxId",
                        "contactId",
                        "displayId",
                        "subject",
                        "status",
                        "priority",
                        "assigneeType",
                        "assigneeId",
                        "channel",
                        "inbound",
                        "lastActivityAt",
                        "firstResponseAt",
                        "resolvedAt",
                        "snoozedUntil",
                        "outcome",
                        "outcomeData",
                        "labelIds",
                        "externalIds",
                        "messageCount",
                        "unreadCount",
                        "autoResolveStage",
                        "autoResolveCandidateAt",
                        "autoResolvePaused",
                        "agentLockUntil",
                        "channelWindowExpiresAt",
                        "relatedConversationId",
                        "workflowRunId",
                        "reopenCount",
                        "version",
                        "createdAt",
                        "updatedAt",
                        "contactLastReadAt",
                        "agentLastReadAt",
                        "deletedAt"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "id",
                    "orgId",
                    "conversationId",
                    "triggerMessageId",
                    "type",
                    "channel",
                    "triggerReason",
                    "confidenceScore",
                    "customerQuery",
                    "conversationSummary",
                    "aiAttemptedResponse",
                    "status",
                    "assignedTo",
                    "resolvedBy",
                    "resolvedAt",
                    "staffResponse",
                    "staffResponseMessageId",
                    "extractedQuestion",
                    "extractedAnswer",
                    "suggestedTags",
                    "extractionConfidence",
                    "knowledgeSourceId",
                    "learningApprovedBy",
                    "learningApprovedAt",
                    "timesRetrieved",
                    "helpfulVotes",
                    "notHelpfulVotes",
                    "createdAt",
                    "updatedAt",
                    "conversation"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/escalations/stats": {
      "get": {
        "operationId": "escalations-stats",
        "summary": "Get escalation statistics",
        "tags": ["Escalations"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "period",
            "schema": {
              "default": "week",
              "type": "string",
              "enum": ["day", "week", "month"]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "period": {
                      "type": "string"
                    },
                    "startDate": {
                      "type": "string"
                    },
                    "endDate": {
                      "type": "string"
                    },
                    "byStatus": {
                      "type": "object",
                      "propertyNames": {
                        "type": "string"
                      },
                      "additionalProperties": {
                        "type": "number"
                      }
                    },
                    "byType": {
                      "type": "object",
                      "propertyNames": {
                        "type": "string"
                      },
                      "additionalProperties": {
                        "type": "number"
                      }
                    },
                    "learning": {
                      "type": "object",
                      "properties": {
                        "totalResolved": {
                          "type": "number"
                        },
                        "learningCreated": {
                          "type": "number"
                        },
                        "adoptionRate": {
                          "type": "number"
                        },
                        "avgExtractionConfidence": {
                          "type": "number"
                        }
                      },
                      "required": [
                        "totalResolved",
                        "learningCreated",
                        "adoptionRate",
                        "avgExtractionConfidence"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": ["period", "startDate", "endDate", "byStatus", "byType", "learning"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/escalations/{id}/assign": {
      "post": {
        "operationId": "escalations-assign",
        "summary": "Assign escalation to staff",
        "tags": ["Escalations"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "assignedTo": {
                    "type": "string"
                  }
                },
                "required": ["orgId", "assignedTo"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "orgId": {
                      "type": "string"
                    },
                    "conversationId": {
                      "type": "string"
                    },
                    "triggerMessageId": {
                      "anyOf": [
                        {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "type": {
                      "type": "string",
                      "enum": [
                        "low_confidence",
                        "keyword_triggered",
                        "tool_failure",
                        "repeated_failure",
                        "explicit_request"
                      ]
                    },
                    "channel": {
                      "type": "string",
                      "enum": [
                        "voice",
                        "sms",
                        "whatsapp",
                        "chat",
                        "email",
                        "instagram",
                        "google_reviews"
                      ]
                    },
                    "triggerReason": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "confidenceScore": {
                      "anyOf": [
                        {
                          "type": "number",
                          "minimum": -8388608,
                          "maximum": 8388607
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "customerQuery": {
                      "type": "string"
                    },
                    "conversationSummary": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "aiAttemptedResponse": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "open",
                        "in_progress",
                        "resolved",
                        "learning_pending",
                        "learning_approved",
                        "dismissed"
                      ]
                    },
                    "assignedTo": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "resolvedBy": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "resolvedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "staffResponse": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "staffResponseMessageId": {
                      "anyOf": [
                        {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "extractedQuestion": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "extractedAnswer": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "suggestedTags": {
                      "anyOf": [
                        {
                          "default": [],
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "extractionConfidence": {
                      "anyOf": [
                        {
                          "type": "number",
                          "minimum": -8388608,
                          "maximum": 8388607
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "knowledgeSourceId": {
                      "anyOf": [
                        {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "learningApprovedBy": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "learningApprovedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "timesRetrieved": {
                      "type": "integer",
                      "minimum": -2147483648,
                      "maximum": 2147483647
                    },
                    "helpfulVotes": {
                      "type": "integer",
                      "minimum": -2147483648,
                      "maximum": 2147483647
                    },
                    "notHelpfulVotes": {
                      "type": "integer",
                      "minimum": -2147483648,
                      "maximum": 2147483647
                    },
                    "createdAt": {
                      "type": "string"
                    },
                    "updatedAt": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "id",
                    "orgId",
                    "conversationId",
                    "triggerMessageId",
                    "type",
                    "channel",
                    "triggerReason",
                    "confidenceScore",
                    "customerQuery",
                    "conversationSummary",
                    "aiAttemptedResponse",
                    "status",
                    "assignedTo",
                    "resolvedBy",
                    "resolvedAt",
                    "staffResponse",
                    "staffResponseMessageId",
                    "extractedQuestion",
                    "extractedAnswer",
                    "suggestedTags",
                    "extractionConfidence",
                    "knowledgeSourceId",
                    "learningApprovedBy",
                    "learningApprovedAt",
                    "timesRetrieved",
                    "helpfulVotes",
                    "notHelpfulVotes",
                    "createdAt",
                    "updatedAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/escalations/{id}/resolve": {
      "post": {
        "operationId": "escalations-resolve",
        "summary": "Resolve escalation",
        "tags": ["Escalations"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "staffResponse": {
                    "type": "string"
                  },
                  "sendMessage": {
                    "default": true,
                    "type": "boolean"
                  }
                },
                "required": ["orgId", "staffResponse"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "orgId": {
                      "type": "string"
                    },
                    "conversationId": {
                      "type": "string"
                    },
                    "triggerMessageId": {
                      "anyOf": [
                        {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "type": {
                      "type": "string",
                      "enum": [
                        "low_confidence",
                        "keyword_triggered",
                        "tool_failure",
                        "repeated_failure",
                        "explicit_request"
                      ]
                    },
                    "channel": {
                      "type": "string",
                      "enum": [
                        "voice",
                        "sms",
                        "whatsapp",
                        "chat",
                        "email",
                        "instagram",
                        "google_reviews"
                      ]
                    },
                    "triggerReason": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "confidenceScore": {
                      "anyOf": [
                        {
                          "type": "number",
                          "minimum": -8388608,
                          "maximum": 8388607
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "customerQuery": {
                      "type": "string"
                    },
                    "conversationSummary": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "aiAttemptedResponse": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "open",
                        "in_progress",
                        "resolved",
                        "learning_pending",
                        "learning_approved",
                        "dismissed"
                      ]
                    },
                    "assignedTo": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "resolvedBy": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "resolvedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "staffResponse": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "staffResponseMessageId": {
                      "anyOf": [
                        {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "extractedQuestion": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "extractedAnswer": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "suggestedTags": {
                      "anyOf": [
                        {
                          "default": [],
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "extractionConfidence": {
                      "anyOf": [
                        {
                          "type": "number",
                          "minimum": -8388608,
                          "maximum": 8388607
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "knowledgeSourceId": {
                      "anyOf": [
                        {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "learningApprovedBy": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "learningApprovedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "timesRetrieved": {
                      "type": "integer",
                      "minimum": -2147483648,
                      "maximum": 2147483647
                    },
                    "helpfulVotes": {
                      "type": "integer",
                      "minimum": -2147483648,
                      "maximum": 2147483647
                    },
                    "notHelpfulVotes": {
                      "type": "integer",
                      "minimum": -2147483648,
                      "maximum": 2147483647
                    },
                    "createdAt": {
                      "type": "string"
                    },
                    "updatedAt": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "id",
                    "orgId",
                    "conversationId",
                    "triggerMessageId",
                    "type",
                    "channel",
                    "triggerReason",
                    "confidenceScore",
                    "customerQuery",
                    "conversationSummary",
                    "aiAttemptedResponse",
                    "status",
                    "assignedTo",
                    "resolvedBy",
                    "resolvedAt",
                    "staffResponse",
                    "staffResponseMessageId",
                    "extractedQuestion",
                    "extractedAnswer",
                    "suggestedTags",
                    "extractionConfidence",
                    "knowledgeSourceId",
                    "learningApprovedBy",
                    "learningApprovedAt",
                    "timesRetrieved",
                    "helpfulVotes",
                    "notHelpfulVotes",
                    "createdAt",
                    "updatedAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/escalations/{id}/dismiss": {
      "post": {
        "operationId": "escalations-dismiss",
        "summary": "Dismiss escalation",
        "tags": ["Escalations"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "reason": {
                    "type": "string"
                  }
                },
                "required": ["orgId"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "orgId": {
                      "type": "string"
                    },
                    "conversationId": {
                      "type": "string"
                    },
                    "triggerMessageId": {
                      "anyOf": [
                        {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "type": {
                      "type": "string",
                      "enum": [
                        "low_confidence",
                        "keyword_triggered",
                        "tool_failure",
                        "repeated_failure",
                        "explicit_request"
                      ]
                    },
                    "channel": {
                      "type": "string",
                      "enum": [
                        "voice",
                        "sms",
                        "whatsapp",
                        "chat",
                        "email",
                        "instagram",
                        "google_reviews"
                      ]
                    },
                    "triggerReason": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "confidenceScore": {
                      "anyOf": [
                        {
                          "type": "number",
                          "minimum": -8388608,
                          "maximum": 8388607
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "customerQuery": {
                      "type": "string"
                    },
                    "conversationSummary": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "aiAttemptedResponse": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "open",
                        "in_progress",
                        "resolved",
                        "learning_pending",
                        "learning_approved",
                        "dismissed"
                      ]
                    },
                    "assignedTo": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "resolvedBy": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "resolvedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "staffResponse": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "staffResponseMessageId": {
                      "anyOf": [
                        {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "extractedQuestion": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "extractedAnswer": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "suggestedTags": {
                      "anyOf": [
                        {
                          "default": [],
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "extractionConfidence": {
                      "anyOf": [
                        {
                          "type": "number",
                          "minimum": -8388608,
                          "maximum": 8388607
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "knowledgeSourceId": {
                      "anyOf": [
                        {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "learningApprovedBy": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "learningApprovedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "timesRetrieved": {
                      "type": "integer",
                      "minimum": -2147483648,
                      "maximum": 2147483647
                    },
                    "helpfulVotes": {
                      "type": "integer",
                      "minimum": -2147483648,
                      "maximum": 2147483647
                    },
                    "notHelpfulVotes": {
                      "type": "integer",
                      "minimum": -2147483648,
                      "maximum": 2147483647
                    },
                    "createdAt": {
                      "type": "string"
                    },
                    "updatedAt": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "id",
                    "orgId",
                    "conversationId",
                    "triggerMessageId",
                    "type",
                    "channel",
                    "triggerReason",
                    "confidenceScore",
                    "customerQuery",
                    "conversationSummary",
                    "aiAttemptedResponse",
                    "status",
                    "assignedTo",
                    "resolvedBy",
                    "resolvedAt",
                    "staffResponse",
                    "staffResponseMessageId",
                    "extractedQuestion",
                    "extractedAnswer",
                    "suggestedTags",
                    "extractionConfidence",
                    "knowledgeSourceId",
                    "learningApprovedBy",
                    "learningApprovedAt",
                    "timesRetrieved",
                    "helpfulVotes",
                    "notHelpfulVotes",
                    "createdAt",
                    "updatedAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/escalations/{id}/extract-learning": {
      "post": {
        "operationId": "escalations-extractLearning",
        "summary": "Extract learning from escalation",
        "tags": ["Escalations"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "extractedQuestion": {
                    "type": "string"
                  },
                  "extractedAnswer": {
                    "type": "string"
                  },
                  "suggestedTags": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                },
                "required": ["orgId"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "orgId": {
                      "type": "string"
                    },
                    "conversationId": {
                      "type": "string"
                    },
                    "triggerMessageId": {
                      "anyOf": [
                        {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "type": {
                      "type": "string",
                      "enum": [
                        "low_confidence",
                        "keyword_triggered",
                        "tool_failure",
                        "repeated_failure",
                        "explicit_request"
                      ]
                    },
                    "channel": {
                      "type": "string",
                      "enum": [
                        "voice",
                        "sms",
                        "whatsapp",
                        "chat",
                        "email",
                        "instagram",
                        "google_reviews"
                      ]
                    },
                    "triggerReason": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "confidenceScore": {
                      "anyOf": [
                        {
                          "type": "number",
                          "minimum": -8388608,
                          "maximum": 8388607
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "customerQuery": {
                      "type": "string"
                    },
                    "conversationSummary": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "aiAttemptedResponse": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "open",
                        "in_progress",
                        "resolved",
                        "learning_pending",
                        "learning_approved",
                        "dismissed"
                      ]
                    },
                    "assignedTo": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "resolvedBy": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "resolvedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "staffResponse": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "staffResponseMessageId": {
                      "anyOf": [
                        {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "extractedQuestion": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "extractedAnswer": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "suggestedTags": {
                      "anyOf": [
                        {
                          "default": [],
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "extractionConfidence": {
                      "anyOf": [
                        {
                          "type": "number",
                          "minimum": -8388608,
                          "maximum": 8388607
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "knowledgeSourceId": {
                      "anyOf": [
                        {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "learningApprovedBy": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "learningApprovedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "timesRetrieved": {
                      "type": "integer",
                      "minimum": -2147483648,
                      "maximum": 2147483647
                    },
                    "helpfulVotes": {
                      "type": "integer",
                      "minimum": -2147483648,
                      "maximum": 2147483647
                    },
                    "notHelpfulVotes": {
                      "type": "integer",
                      "minimum": -2147483648,
                      "maximum": 2147483647
                    },
                    "createdAt": {
                      "type": "string"
                    },
                    "updatedAt": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "id",
                    "orgId",
                    "conversationId",
                    "triggerMessageId",
                    "type",
                    "channel",
                    "triggerReason",
                    "confidenceScore",
                    "customerQuery",
                    "conversationSummary",
                    "aiAttemptedResponse",
                    "status",
                    "assignedTo",
                    "resolvedBy",
                    "resolvedAt",
                    "staffResponse",
                    "staffResponseMessageId",
                    "extractedQuestion",
                    "extractedAnswer",
                    "suggestedTags",
                    "extractionConfidence",
                    "knowledgeSourceId",
                    "learningApprovedBy",
                    "learningApprovedAt",
                    "timesRetrieved",
                    "helpfulVotes",
                    "notHelpfulVotes",
                    "createdAt",
                    "updatedAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/escalations/{id}/approve-learning": {
      "post": {
        "operationId": "escalations-approveLearning",
        "summary": "Approve learning and create knowledge",
        "tags": ["Escalations"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "question": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 2000
                  },
                  "answer": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 10000
                  },
                  "tags": {
                    "maxItems": 20,
                    "type": "array",
                    "items": {
                      "type": "string",
                      "maxLength": 100
                    }
                  }
                },
                "required": ["orgId", "question", "answer"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "escalation": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "orgId": {
                          "type": "string"
                        },
                        "conversationId": {
                          "type": "string"
                        },
                        "triggerMessageId": {
                          "anyOf": [
                            {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "type": {
                          "type": "string",
                          "enum": [
                            "low_confidence",
                            "keyword_triggered",
                            "tool_failure",
                            "repeated_failure",
                            "explicit_request"
                          ]
                        },
                        "channel": {
                          "type": "string",
                          "enum": [
                            "voice",
                            "sms",
                            "whatsapp",
                            "chat",
                            "email",
                            "instagram",
                            "google_reviews"
                          ]
                        },
                        "triggerReason": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "confidenceScore": {
                          "anyOf": [
                            {
                              "type": "number",
                              "minimum": -8388608,
                              "maximum": 8388607
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "customerQuery": {
                          "type": "string"
                        },
                        "conversationSummary": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "aiAttemptedResponse": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "status": {
                          "type": "string",
                          "enum": [
                            "open",
                            "in_progress",
                            "resolved",
                            "learning_pending",
                            "learning_approved",
                            "dismissed"
                          ]
                        },
                        "assignedTo": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "resolvedBy": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "resolvedAt": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "staffResponse": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "staffResponseMessageId": {
                          "anyOf": [
                            {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "extractedQuestion": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "extractedAnswer": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "suggestedTags": {
                          "anyOf": [
                            {
                              "default": [],
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "extractionConfidence": {
                          "anyOf": [
                            {
                              "type": "number",
                              "minimum": -8388608,
                              "maximum": 8388607
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "knowledgeSourceId": {
                          "anyOf": [
                            {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "learningApprovedBy": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "learningApprovedAt": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "timesRetrieved": {
                          "type": "integer",
                          "minimum": -2147483648,
                          "maximum": 2147483647
                        },
                        "helpfulVotes": {
                          "type": "integer",
                          "minimum": -2147483648,
                          "maximum": 2147483647
                        },
                        "notHelpfulVotes": {
                          "type": "integer",
                          "minimum": -2147483648,
                          "maximum": 2147483647
                        },
                        "createdAt": {
                          "type": "string"
                        },
                        "updatedAt": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "id",
                        "orgId",
                        "conversationId",
                        "triggerMessageId",
                        "type",
                        "channel",
                        "triggerReason",
                        "confidenceScore",
                        "customerQuery",
                        "conversationSummary",
                        "aiAttemptedResponse",
                        "status",
                        "assignedTo",
                        "resolvedBy",
                        "resolvedAt",
                        "staffResponse",
                        "staffResponseMessageId",
                        "extractedQuestion",
                        "extractedAnswer",
                        "suggestedTags",
                        "extractionConfidence",
                        "knowledgeSourceId",
                        "learningApprovedBy",
                        "learningApprovedAt",
                        "timesRetrieved",
                        "helpfulVotes",
                        "notHelpfulVotes",
                        "createdAt",
                        "updatedAt"
                      ],
                      "additionalProperties": false
                    },
                    "knowledgeSource": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "orgId": {
                          "type": "string"
                        },
                        "name": {
                          "type": "string"
                        },
                        "config": {
                          "anyOf": [
                            {
                              "type": "object",
                              "properties": {
                                "type": {
                                  "type": "string",
                                  "const": "faq"
                                },
                                "pairs": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "question": {
                                        "type": "string"
                                      },
                                      "answer": {
                                        "type": "string"
                                      },
                                      "category": {
                                        "type": "string"
                                      }
                                    },
                                    "required": ["question", "answer"],
                                    "additionalProperties": false
                                  }
                                }
                              },
                              "required": ["type", "pairs"],
                              "additionalProperties": false
                            },
                            {
                              "type": "object",
                              "properties": {
                                "type": {
                                  "type": "string",
                                  "const": "document"
                                },
                                "fileKey": {
                                  "type": "string"
                                },
                                "fileName": {
                                  "type": "string"
                                },
                                "mimeType": {
                                  "type": "string"
                                },
                                "fileSize": {
                                  "type": "integer",
                                  "minimum": -9007199254740991,
                                  "maximum": 9007199254740991
                                },
                                "chunkSize": {
                                  "type": "integer",
                                  "minimum": -9007199254740991,
                                  "maximum": 9007199254740991
                                },
                                "chunkOverlap": {
                                  "type": "integer",
                                  "minimum": -9007199254740991,
                                  "maximum": 9007199254740991
                                }
                              },
                              "required": [
                                "type",
                                "fileKey",
                                "fileName",
                                "mimeType",
                                "chunkSize",
                                "chunkOverlap"
                              ],
                              "additionalProperties": false
                            },
                            {
                              "type": "object",
                              "properties": {
                                "type": {
                                  "type": "string",
                                  "const": "webpage"
                                },
                                "url": {
                                  "type": "string"
                                },
                                "refreshIntervalHours": {
                                  "type": "integer",
                                  "minimum": -9007199254740991,
                                  "maximum": 9007199254740991
                                },
                                "selector": {
                                  "type": "string"
                                },
                                "excludeSelectors": {
                                  "type": "array",
                                  "items": {
                                    "type": "string"
                                  }
                                },
                                "crawl": {
                                  "type": "boolean"
                                },
                                "maxDepth": {
                                  "type": "integer",
                                  "minimum": -9007199254740991,
                                  "maximum": 9007199254740991
                                },
                                "maxPages": {
                                  "type": "integer",
                                  "minimum": -9007199254740991,
                                  "maximum": 9007199254740991
                                },
                                "crawlInstructions": {
                                  "type": "string"
                                }
                              },
                              "required": ["type", "url", "refreshIntervalHours"],
                              "additionalProperties": false
                            },
                            {
                              "type": "object",
                              "properties": {
                                "type": {
                                  "type": "string",
                                  "const": "custom"
                                },
                                "content": {
                                  "type": "string"
                                },
                                "title": {
                                  "type": "string"
                                }
                              },
                              "required": ["type", "content"],
                              "additionalProperties": false
                            }
                          ]
                        },
                        "status": {
                          "type": "string",
                          "enum": ["pending", "processing", "ready", "error"]
                        },
                        "errorMessage": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "chunkCount": {
                          "type": "integer",
                          "minimum": -2147483648,
                          "maximum": 2147483647
                        },
                        "lastSyncedAt": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "createdAt": {
                          "type": "string"
                        },
                        "updatedAt": {
                          "type": "string"
                        },
                        "deletedAt": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      },
                      "required": [
                        "id",
                        "orgId",
                        "name",
                        "config",
                        "status",
                        "errorMessage",
                        "chunkCount",
                        "lastSyncedAt",
                        "createdAt",
                        "updatedAt",
                        "deletedAt"
                      ],
                      "additionalProperties": false
                    },
                    "knowledgeChunk": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "orgId": {
                          "type": "string"
                        },
                        "sourceId": {
                          "type": "string"
                        },
                        "title": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "content": {
                          "type": "string"
                        },
                        "contentType": {
                          "type": "string",
                          "enum": [
                            "concept_explanation",
                            "how_to_guide",
                            "feature_description",
                            "pricing_info",
                            "faq",
                            "comparison",
                            "tutorial",
                            "reference",
                            "text",
                            "faq_question",
                            "faq_answer"
                          ]
                        },
                        "importance": {
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": ["critical", "important", "supplementary"]
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "questionsAnswered": {
                          "anyOf": [
                            {
                              "default": [],
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "topics": {
                          "anyOf": [
                            {
                              "default": [],
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "keywords": {
                          "anyOf": [
                            {
                              "default": [],
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "pageUrl": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "sectionHeading": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "webpageMetadata": {
                          "anyOf": [
                            {
                              "anyOf": [
                                {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "number"
                                    },
                                    {
                                      "type": "boolean"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                {
                                  "type": "object",
                                  "propertyNames": {
                                    "type": "string"
                                  },
                                  "additionalProperties": {}
                                },
                                {
                                  "type": "array",
                                  "items": {}
                                }
                              ]
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "documentMetadata": {
                          "anyOf": [
                            {
                              "anyOf": [
                                {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "number"
                                    },
                                    {
                                      "type": "boolean"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                {
                                  "type": "object",
                                  "propertyNames": {
                                    "type": "string"
                                  },
                                  "additionalProperties": {}
                                },
                                {
                                  "type": "array",
                                  "items": {}
                                }
                              ]
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "faqMetadata": {
                          "anyOf": [
                            {
                              "anyOf": [
                                {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "number"
                                    },
                                    {
                                      "type": "boolean"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                {
                                  "type": "object",
                                  "propertyNames": {
                                    "type": "string"
                                  },
                                  "additionalProperties": {}
                                },
                                {
                                  "type": "array",
                                  "items": {}
                                }
                              ]
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "customMetadata": {
                          "anyOf": [
                            {
                              "anyOf": [
                                {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "number"
                                    },
                                    {
                                      "type": "boolean"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                {
                                  "type": "object",
                                  "propertyNames": {
                                    "type": "string"
                                  },
                                  "additionalProperties": {}
                                },
                                {
                                  "type": "array",
                                  "items": {}
                                }
                              ]
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "chunkIndex": {
                          "type": "integer",
                          "minimum": -2147483648,
                          "maximum": 2147483647
                        },
                        "parentId": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "metadata": {
                          "default": {},
                          "type": "object",
                          "propertyNames": {
                            "type": "string"
                          },
                          "additionalProperties": {}
                        },
                        "createdAt": {
                          "type": "string"
                        },
                        "updatedAt": {
                          "type": "string"
                        },
                        "deletedAt": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      },
                      "required": [
                        "id",
                        "orgId",
                        "sourceId",
                        "title",
                        "content",
                        "contentType",
                        "importance",
                        "questionsAnswered",
                        "topics",
                        "keywords",
                        "pageUrl",
                        "sectionHeading",
                        "webpageMetadata",
                        "documentMetadata",
                        "faqMetadata",
                        "customMetadata",
                        "chunkIndex",
                        "parentId",
                        "metadata",
                        "createdAt",
                        "updatedAt",
                        "deletedAt"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": ["escalation", "knowledgeSource", "knowledgeChunk"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/canned-responses": {
      "get": {
        "operationId": "cannedResponses-list",
        "summary": "List canned responses",
        "tags": ["Canned Responses"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "search",
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "category",
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "limit",
            "schema": {
              "default": 50,
              "type": "number",
              "minimum": 1,
              "maximum": 100
            }
          },
          {
            "in": "query",
            "name": "offset",
            "schema": {
              "default": 0,
              "type": "number",
              "minimum": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "cannedResponses": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "orgId": {
                            "type": "string"
                          },
                          "title": {
                            "type": "string"
                          },
                          "shortcut": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "content": {
                            "type": "string"
                          },
                          "contentType": {
                            "type": "string"
                          },
                          "category": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "tags": {
                            "default": [],
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "scope": {
                            "type": "string",
                            "enum": ["user", "team", "workspace"]
                          },
                          "createdById": {
                            "type": "string"
                          },
                          "createdAt": {
                            "type": "string"
                          },
                          "updatedAt": {
                            "type": "string"
                          },
                          "deletedAt": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        },
                        "required": [
                          "id",
                          "orgId",
                          "title",
                          "shortcut",
                          "content",
                          "contentType",
                          "category",
                          "tags",
                          "scope",
                          "createdById",
                          "createdAt",
                          "updatedAt",
                          "deletedAt"
                        ],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": ["cannedResponses"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "cannedResponses-create",
        "summary": "Create a new canned response",
        "tags": ["Canned Responses"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "title": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100
                  },
                  "shortcut": {
                    "type": "string",
                    "maxLength": 20
                  },
                  "content": {
                    "type": "string",
                    "minLength": 1
                  },
                  "contentType": {
                    "type": "string",
                    "enum": ["text", "template"]
                  },
                  "category": {
                    "type": "string"
                  },
                  "tags": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "scope": {
                    "type": "string",
                    "enum": ["user", "team", "workspace"]
                  }
                },
                "required": ["orgId", "title", "content"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "orgId": {
                      "type": "string"
                    },
                    "title": {
                      "type": "string"
                    },
                    "shortcut": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "content": {
                      "type": "string"
                    },
                    "contentType": {
                      "type": "string"
                    },
                    "category": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "tags": {
                      "default": [],
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "scope": {
                      "type": "string",
                      "enum": ["user", "team", "workspace"]
                    },
                    "createdById": {
                      "type": "string"
                    },
                    "createdAt": {
                      "type": "string"
                    },
                    "updatedAt": {
                      "type": "string"
                    },
                    "deletedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": [
                    "id",
                    "orgId",
                    "title",
                    "shortcut",
                    "content",
                    "contentType",
                    "category",
                    "tags",
                    "scope",
                    "createdById",
                    "createdAt",
                    "updatedAt",
                    "deletedAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/canned-responses/{id}": {
      "get": {
        "operationId": "cannedResponses-get",
        "summary": "Get canned response by ID",
        "tags": ["Canned Responses"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "orgId": {
                      "type": "string"
                    },
                    "title": {
                      "type": "string"
                    },
                    "shortcut": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "content": {
                      "type": "string"
                    },
                    "contentType": {
                      "type": "string"
                    },
                    "category": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "tags": {
                      "default": [],
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "scope": {
                      "type": "string",
                      "enum": ["user", "team", "workspace"]
                    },
                    "createdById": {
                      "type": "string"
                    },
                    "createdAt": {
                      "type": "string"
                    },
                    "updatedAt": {
                      "type": "string"
                    },
                    "deletedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": [
                    "id",
                    "orgId",
                    "title",
                    "shortcut",
                    "content",
                    "contentType",
                    "category",
                    "tags",
                    "scope",
                    "createdById",
                    "createdAt",
                    "updatedAt",
                    "deletedAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "cannedResponses-update",
        "summary": "Update a canned response",
        "tags": ["Canned Responses"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "title": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100
                  },
                  "shortcut": {
                    "type": "string",
                    "maxLength": 20
                  },
                  "content": {
                    "type": "string",
                    "minLength": 1
                  },
                  "contentType": {
                    "type": "string",
                    "enum": ["text", "template"]
                  },
                  "category": {
                    "type": "string"
                  },
                  "tags": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "scope": {
                    "type": "string",
                    "enum": ["user", "team", "workspace"]
                  }
                },
                "required": ["orgId"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "orgId": {
                      "type": "string"
                    },
                    "title": {
                      "type": "string"
                    },
                    "shortcut": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "content": {
                      "type": "string"
                    },
                    "contentType": {
                      "type": "string"
                    },
                    "category": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "tags": {
                      "default": [],
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "scope": {
                      "type": "string",
                      "enum": ["user", "team", "workspace"]
                    },
                    "createdById": {
                      "type": "string"
                    },
                    "createdAt": {
                      "type": "string"
                    },
                    "updatedAt": {
                      "type": "string"
                    },
                    "deletedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": [
                    "id",
                    "orgId",
                    "title",
                    "shortcut",
                    "content",
                    "contentType",
                    "category",
                    "tags",
                    "scope",
                    "createdById",
                    "createdAt",
                    "updatedAt",
                    "deletedAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "cannedResponses-delete",
        "summary": "Delete a canned response",
        "tags": ["Canned Responses"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    }
                  },
                  "required": ["success"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/knowledge/stats": {
      "get": {
        "operationId": "knowledge-stats",
        "summary": "Get knowledge base stats",
        "tags": ["Knowledge"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "sourceCount": {
                      "type": "number"
                    },
                    "chunkCount": {
                      "type": "number"
                    },
                    "learnedCount": {
                      "type": "number"
                    },
                    "lastUpdatedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": ["sourceCount", "chunkCount", "learnedCount", "lastUpdatedAt"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/knowledge/sources": {
      "get": {
        "operationId": "knowledge-list",
        "summary": "List knowledge sources",
        "tags": ["Knowledge"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "type",
            "schema": {
              "type": "string",
              "enum": ["faq", "document", "webpage", "custom"]
            }
          },
          {
            "in": "query",
            "name": "status",
            "schema": {
              "type": "string",
              "enum": ["pending", "processing", "ready", "error"]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "sources": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "orgId": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "config": {
                            "anyOf": [
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "faq"
                                  },
                                  "pairs": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "question": {
                                          "type": "string"
                                        },
                                        "answer": {
                                          "type": "string"
                                        },
                                        "category": {
                                          "type": "string"
                                        }
                                      },
                                      "required": ["question", "answer"],
                                      "additionalProperties": false
                                    }
                                  }
                                },
                                "required": ["type", "pairs"],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "document"
                                  },
                                  "fileKey": {
                                    "type": "string"
                                  },
                                  "fileName": {
                                    "type": "string"
                                  },
                                  "mimeType": {
                                    "type": "string"
                                  },
                                  "fileSize": {
                                    "type": "integer",
                                    "minimum": -9007199254740991,
                                    "maximum": 9007199254740991
                                  },
                                  "chunkSize": {
                                    "type": "integer",
                                    "minimum": -9007199254740991,
                                    "maximum": 9007199254740991
                                  },
                                  "chunkOverlap": {
                                    "type": "integer",
                                    "minimum": -9007199254740991,
                                    "maximum": 9007199254740991
                                  }
                                },
                                "required": [
                                  "type",
                                  "fileKey",
                                  "fileName",
                                  "mimeType",
                                  "chunkSize",
                                  "chunkOverlap"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "webpage"
                                  },
                                  "url": {
                                    "type": "string"
                                  },
                                  "refreshIntervalHours": {
                                    "type": "integer",
                                    "minimum": -9007199254740991,
                                    "maximum": 9007199254740991
                                  },
                                  "selector": {
                                    "type": "string"
                                  },
                                  "excludeSelectors": {
                                    "type": "array",
                                    "items": {
                                      "type": "string"
                                    }
                                  },
                                  "crawl": {
                                    "type": "boolean"
                                  },
                                  "maxDepth": {
                                    "type": "integer",
                                    "minimum": -9007199254740991,
                                    "maximum": 9007199254740991
                                  },
                                  "maxPages": {
                                    "type": "integer",
                                    "minimum": -9007199254740991,
                                    "maximum": 9007199254740991
                                  },
                                  "crawlInstructions": {
                                    "type": "string"
                                  }
                                },
                                "required": ["type", "url", "refreshIntervalHours"],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "const": "custom"
                                  },
                                  "content": {
                                    "type": "string"
                                  },
                                  "title": {
                                    "type": "string"
                                  }
                                },
                                "required": ["type", "content"],
                                "additionalProperties": false
                              }
                            ]
                          },
                          "status": {
                            "type": "string",
                            "enum": ["pending", "processing", "ready", "error"]
                          },
                          "errorMessage": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "chunkCount": {
                            "type": "integer",
                            "minimum": -2147483648,
                            "maximum": 2147483647
                          },
                          "lastSyncedAt": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "createdAt": {
                            "type": "string"
                          },
                          "updatedAt": {
                            "type": "string"
                          },
                          "deletedAt": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        },
                        "required": [
                          "id",
                          "orgId",
                          "name",
                          "config",
                          "status",
                          "errorMessage",
                          "chunkCount",
                          "lastSyncedAt",
                          "createdAt",
                          "updatedAt",
                          "deletedAt"
                        ],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": ["sources"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "knowledge-create",
        "summary": "Create a knowledge source",
        "tags": ["Knowledge"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100
                  },
                  "config": {
                    "oneOf": [
                      {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string",
                            "const": "faq"
                          },
                          "pairs": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "question": {
                                  "type": "string"
                                },
                                "answer": {
                                  "type": "string"
                                },
                                "category": {
                                  "type": "string"
                                }
                              },
                              "required": ["question", "answer"]
                            }
                          }
                        },
                        "required": ["type", "pairs"]
                      },
                      {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string",
                            "const": "document"
                          },
                          "fileKey": {
                            "type": "string"
                          },
                          "fileName": {
                            "type": "string"
                          },
                          "mimeType": {
                            "type": "string"
                          },
                          "fileSize": {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991
                          },
                          "chunkSize": {
                            "default": 500,
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991
                          },
                          "chunkOverlap": {
                            "default": 50,
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991
                          }
                        },
                        "required": ["type", "fileKey", "fileName", "mimeType"]
                      },
                      {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string",
                            "const": "webpage"
                          },
                          "url": {
                            "type": "string",
                            "format": "uri"
                          },
                          "refreshIntervalHours": {
                            "default": 24,
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991
                          },
                          "selector": {
                            "type": "string"
                          },
                          "excludeSelectors": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "crawl": {
                            "default": false,
                            "type": "boolean"
                          },
                          "maxDepth": {
                            "default": 1,
                            "type": "integer",
                            "minimum": 1,
                            "maximum": 3
                          },
                          "maxPages": {
                            "default": 10,
                            "type": "integer",
                            "minimum": 1,
                            "maximum": 50
                          },
                          "crawlInstructions": {
                            "type": "string"
                          }
                        },
                        "required": ["type", "url"]
                      },
                      {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string",
                            "const": "custom"
                          },
                          "content": {
                            "type": "string"
                          },
                          "title": {
                            "type": "string"
                          }
                        },
                        "required": ["type", "content"]
                      }
                    ],
                    "type": "object"
                  }
                },
                "required": ["orgId", "name", "config"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "orgId": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "config": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "faq"
                            },
                            "pairs": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "question": {
                                    "type": "string"
                                  },
                                  "answer": {
                                    "type": "string"
                                  },
                                  "category": {
                                    "type": "string"
                                  }
                                },
                                "required": ["question", "answer"],
                                "additionalProperties": false
                              }
                            }
                          },
                          "required": ["type", "pairs"],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "document"
                            },
                            "fileKey": {
                              "type": "string"
                            },
                            "fileName": {
                              "type": "string"
                            },
                            "mimeType": {
                              "type": "string"
                            },
                            "fileSize": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991
                            },
                            "chunkSize": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991
                            },
                            "chunkOverlap": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991
                            }
                          },
                          "required": [
                            "type",
                            "fileKey",
                            "fileName",
                            "mimeType",
                            "chunkSize",
                            "chunkOverlap"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "webpage"
                            },
                            "url": {
                              "type": "string"
                            },
                            "refreshIntervalHours": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991
                            },
                            "selector": {
                              "type": "string"
                            },
                            "excludeSelectors": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "crawl": {
                              "type": "boolean"
                            },
                            "maxDepth": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991
                            },
                            "maxPages": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991
                            },
                            "crawlInstructions": {
                              "type": "string"
                            }
                          },
                          "required": ["type", "url", "refreshIntervalHours"],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "custom"
                            },
                            "content": {
                              "type": "string"
                            },
                            "title": {
                              "type": "string"
                            }
                          },
                          "required": ["type", "content"],
                          "additionalProperties": false
                        }
                      ]
                    },
                    "status": {
                      "type": "string",
                      "enum": ["pending", "processing", "ready", "error"]
                    },
                    "errorMessage": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "chunkCount": {
                      "type": "integer",
                      "minimum": -2147483648,
                      "maximum": 2147483647
                    },
                    "lastSyncedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "createdAt": {
                      "type": "string"
                    },
                    "updatedAt": {
                      "type": "string"
                    },
                    "deletedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": [
                    "id",
                    "orgId",
                    "name",
                    "config",
                    "status",
                    "errorMessage",
                    "chunkCount",
                    "lastSyncedAt",
                    "createdAt",
                    "updatedAt",
                    "deletedAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/knowledge/sources/{id}": {
      "get": {
        "operationId": "knowledge-get",
        "summary": "Get knowledge source by ID",
        "tags": ["Knowledge"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "orgId": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "config": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "faq"
                            },
                            "pairs": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "question": {
                                    "type": "string"
                                  },
                                  "answer": {
                                    "type": "string"
                                  },
                                  "category": {
                                    "type": "string"
                                  }
                                },
                                "required": ["question", "answer"],
                                "additionalProperties": false
                              }
                            }
                          },
                          "required": ["type", "pairs"],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "document"
                            },
                            "fileKey": {
                              "type": "string"
                            },
                            "fileName": {
                              "type": "string"
                            },
                            "mimeType": {
                              "type": "string"
                            },
                            "fileSize": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991
                            },
                            "chunkSize": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991
                            },
                            "chunkOverlap": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991
                            }
                          },
                          "required": [
                            "type",
                            "fileKey",
                            "fileName",
                            "mimeType",
                            "chunkSize",
                            "chunkOverlap"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "webpage"
                            },
                            "url": {
                              "type": "string"
                            },
                            "refreshIntervalHours": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991
                            },
                            "selector": {
                              "type": "string"
                            },
                            "excludeSelectors": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "crawl": {
                              "type": "boolean"
                            },
                            "maxDepth": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991
                            },
                            "maxPages": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991
                            },
                            "crawlInstructions": {
                              "type": "string"
                            }
                          },
                          "required": ["type", "url", "refreshIntervalHours"],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "custom"
                            },
                            "content": {
                              "type": "string"
                            },
                            "title": {
                              "type": "string"
                            }
                          },
                          "required": ["type", "content"],
                          "additionalProperties": false
                        }
                      ]
                    },
                    "status": {
                      "type": "string",
                      "enum": ["pending", "processing", "ready", "error"]
                    },
                    "errorMessage": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "chunkCount": {
                      "type": "integer",
                      "minimum": -2147483648,
                      "maximum": 2147483647
                    },
                    "lastSyncedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "createdAt": {
                      "type": "string"
                    },
                    "updatedAt": {
                      "type": "string"
                    },
                    "deletedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": [
                    "id",
                    "orgId",
                    "name",
                    "config",
                    "status",
                    "errorMessage",
                    "chunkCount",
                    "lastSyncedAt",
                    "createdAt",
                    "updatedAt",
                    "deletedAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "knowledge-update",
        "summary": "Update a knowledge source",
        "tags": ["Knowledge"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100
                  },
                  "config": {
                    "oneOf": [
                      {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string",
                            "const": "faq"
                          },
                          "pairs": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "question": {
                                  "type": "string"
                                },
                                "answer": {
                                  "type": "string"
                                },
                                "category": {
                                  "type": "string"
                                }
                              },
                              "required": ["question", "answer"]
                            }
                          }
                        },
                        "required": ["type", "pairs"]
                      },
                      {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string",
                            "const": "document"
                          },
                          "fileKey": {
                            "type": "string"
                          },
                          "fileName": {
                            "type": "string"
                          },
                          "mimeType": {
                            "type": "string"
                          },
                          "fileSize": {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991
                          },
                          "chunkSize": {
                            "default": 500,
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991
                          },
                          "chunkOverlap": {
                            "default": 50,
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991
                          }
                        },
                        "required": ["type", "fileKey", "fileName", "mimeType"]
                      },
                      {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string",
                            "const": "webpage"
                          },
                          "url": {
                            "type": "string",
                            "format": "uri"
                          },
                          "refreshIntervalHours": {
                            "default": 24,
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991
                          },
                          "selector": {
                            "type": "string"
                          },
                          "excludeSelectors": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "crawl": {
                            "default": false,
                            "type": "boolean"
                          },
                          "maxDepth": {
                            "default": 1,
                            "type": "integer",
                            "minimum": 1,
                            "maximum": 3
                          },
                          "maxPages": {
                            "default": 10,
                            "type": "integer",
                            "minimum": 1,
                            "maximum": 50
                          },
                          "crawlInstructions": {
                            "type": "string"
                          }
                        },
                        "required": ["type", "url"]
                      },
                      {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string",
                            "const": "custom"
                          },
                          "content": {
                            "type": "string"
                          },
                          "title": {
                            "type": "string"
                          }
                        },
                        "required": ["type", "content"]
                      }
                    ],
                    "type": "object"
                  }
                },
                "required": ["orgId"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "orgId": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "config": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "faq"
                            },
                            "pairs": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "question": {
                                    "type": "string"
                                  },
                                  "answer": {
                                    "type": "string"
                                  },
                                  "category": {
                                    "type": "string"
                                  }
                                },
                                "required": ["question", "answer"],
                                "additionalProperties": false
                              }
                            }
                          },
                          "required": ["type", "pairs"],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "document"
                            },
                            "fileKey": {
                              "type": "string"
                            },
                            "fileName": {
                              "type": "string"
                            },
                            "mimeType": {
                              "type": "string"
                            },
                            "fileSize": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991
                            },
                            "chunkSize": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991
                            },
                            "chunkOverlap": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991
                            }
                          },
                          "required": [
                            "type",
                            "fileKey",
                            "fileName",
                            "mimeType",
                            "chunkSize",
                            "chunkOverlap"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "webpage"
                            },
                            "url": {
                              "type": "string"
                            },
                            "refreshIntervalHours": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991
                            },
                            "selector": {
                              "type": "string"
                            },
                            "excludeSelectors": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "crawl": {
                              "type": "boolean"
                            },
                            "maxDepth": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991
                            },
                            "maxPages": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991
                            },
                            "crawlInstructions": {
                              "type": "string"
                            }
                          },
                          "required": ["type", "url", "refreshIntervalHours"],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "custom"
                            },
                            "content": {
                              "type": "string"
                            },
                            "title": {
                              "type": "string"
                            }
                          },
                          "required": ["type", "content"],
                          "additionalProperties": false
                        }
                      ]
                    },
                    "status": {
                      "type": "string",
                      "enum": ["pending", "processing", "ready", "error"]
                    },
                    "errorMessage": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "chunkCount": {
                      "type": "integer",
                      "minimum": -2147483648,
                      "maximum": 2147483647
                    },
                    "lastSyncedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "createdAt": {
                      "type": "string"
                    },
                    "updatedAt": {
                      "type": "string"
                    },
                    "deletedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": [
                    "id",
                    "orgId",
                    "name",
                    "config",
                    "status",
                    "errorMessage",
                    "chunkCount",
                    "lastSyncedAt",
                    "createdAt",
                    "updatedAt",
                    "deletedAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "knowledge-delete",
        "summary": "Delete a knowledge source",
        "tags": ["Knowledge"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    }
                  },
                  "required": ["success"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/knowledge/sources/{id}/chunks": {
      "get": {
        "operationId": "knowledge-listChunks",
        "summary": "List chunks for a knowledge source",
        "tags": ["Knowledge"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "chunks": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "title": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "content": {
                            "type": "string"
                          },
                          "contentType": {
                            "type": "string",
                            "enum": [
                              "concept_explanation",
                              "how_to_guide",
                              "feature_description",
                              "pricing_info",
                              "faq",
                              "comparison",
                              "tutorial",
                              "reference",
                              "text",
                              "faq_question",
                              "faq_answer"
                            ]
                          },
                          "chunkIndex": {
                            "type": "integer",
                            "minimum": -2147483648,
                            "maximum": 2147483647
                          },
                          "metadata": {
                            "default": {},
                            "type": "object",
                            "propertyNames": {
                              "type": "string"
                            },
                            "additionalProperties": {}
                          },
                          "importance": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": ["critical", "important", "supplementary"]
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "questionsAnswered": {
                            "anyOf": [
                              {
                                "default": [],
                                "type": "array",
                                "items": {
                                  "type": "string"
                                }
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "topics": {
                            "anyOf": [
                              {
                                "default": [],
                                "type": "array",
                                "items": {
                                  "type": "string"
                                }
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "keywords": {
                            "anyOf": [
                              {
                                "default": [],
                                "type": "array",
                                "items": {
                                  "type": "string"
                                }
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "webpageMetadata": {
                            "anyOf": [
                              {
                                "anyOf": [
                                  {
                                    "anyOf": [
                                      {
                                        "type": "string"
                                      },
                                      {
                                        "type": "number"
                                      },
                                      {
                                        "type": "boolean"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  {
                                    "type": "object",
                                    "propertyNames": {
                                      "type": "string"
                                    },
                                    "additionalProperties": {}
                                  },
                                  {
                                    "type": "array",
                                    "items": {}
                                  }
                                ]
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "documentMetadata": {
                            "anyOf": [
                              {
                                "anyOf": [
                                  {
                                    "anyOf": [
                                      {
                                        "type": "string"
                                      },
                                      {
                                        "type": "number"
                                      },
                                      {
                                        "type": "boolean"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  {
                                    "type": "object",
                                    "propertyNames": {
                                      "type": "string"
                                    },
                                    "additionalProperties": {}
                                  },
                                  {
                                    "type": "array",
                                    "items": {}
                                  }
                                ]
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "faqMetadata": {
                            "anyOf": [
                              {
                                "anyOf": [
                                  {
                                    "anyOf": [
                                      {
                                        "type": "string"
                                      },
                                      {
                                        "type": "number"
                                      },
                                      {
                                        "type": "boolean"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  {
                                    "type": "object",
                                    "propertyNames": {
                                      "type": "string"
                                    },
                                    "additionalProperties": {}
                                  },
                                  {
                                    "type": "array",
                                    "items": {}
                                  }
                                ]
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "customMetadata": {
                            "anyOf": [
                              {
                                "anyOf": [
                                  {
                                    "anyOf": [
                                      {
                                        "type": "string"
                                      },
                                      {
                                        "type": "number"
                                      },
                                      {
                                        "type": "boolean"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  {
                                    "type": "object",
                                    "propertyNames": {
                                      "type": "string"
                                    },
                                    "additionalProperties": {}
                                  },
                                  {
                                    "type": "array",
                                    "items": {}
                                  }
                                ]
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        },
                        "required": [
                          "id",
                          "title",
                          "content",
                          "contentType",
                          "chunkIndex",
                          "metadata",
                          "importance",
                          "questionsAnswered",
                          "topics",
                          "keywords",
                          "webpageMetadata",
                          "documentMetadata",
                          "faqMetadata",
                          "customMetadata"
                        ],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": ["chunks"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/knowledge/search": {
      "get": {
        "operationId": "knowledge-search",
        "summary": "Search across all knowledge chunks in organization",
        "tags": ["Knowledge"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "sourceType",
            "schema": {
              "type": "string",
              "enum": ["faq", "document", "webpage", "custom"]
            }
          },
          {
            "in": "query",
            "name": "sourceIds",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          },
          {
            "in": "query",
            "name": "importance",
            "schema": {
              "type": "string",
              "enum": ["critical", "important", "supplementary"]
            }
          },
          {
            "in": "query",
            "name": "topics",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          },
          {
            "in": "query",
            "name": "limit",
            "schema": {
              "default": 20,
              "type": "integer",
              "minimum": 1,
              "maximum": 100
            }
          },
          {
            "in": "query",
            "name": "offset",
            "schema": {
              "default": 0,
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            }
          },
          {
            "in": "query",
            "name": "sort",
            "schema": {
              "default": "relevance",
              "type": "string",
              "enum": ["relevance", "date", "importance"]
            }
          },
          {
            "in": "query",
            "name": "sortOrder",
            "schema": {
              "default": "desc",
              "type": "string",
              "enum": ["asc", "desc"]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "chunks": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "title": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "content": {
                            "type": "string"
                          },
                          "contentType": {
                            "type": "string",
                            "enum": [
                              "concept_explanation",
                              "how_to_guide",
                              "feature_description",
                              "pricing_info",
                              "faq",
                              "comparison",
                              "tutorial",
                              "reference",
                              "text",
                              "faq_question",
                              "faq_answer"
                            ]
                          },
                          "chunkIndex": {
                            "type": "integer",
                            "minimum": -2147483648,
                            "maximum": 2147483647
                          },
                          "metadata": {
                            "default": {},
                            "type": "object",
                            "propertyNames": {
                              "type": "string"
                            },
                            "additionalProperties": {}
                          },
                          "importance": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": ["critical", "important", "supplementary"]
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "questionsAnswered": {
                            "anyOf": [
                              {
                                "default": [],
                                "type": "array",
                                "items": {
                                  "type": "string"
                                }
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "topics": {
                            "anyOf": [
                              {
                                "default": [],
                                "type": "array",
                                "items": {
                                  "type": "string"
                                }
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "keywords": {
                            "anyOf": [
                              {
                                "default": [],
                                "type": "array",
                                "items": {
                                  "type": "string"
                                }
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "webpageMetadata": {
                            "anyOf": [
                              {
                                "anyOf": [
                                  {
                                    "anyOf": [
                                      {
                                        "type": "string"
                                      },
                                      {
                                        "type": "number"
                                      },
                                      {
                                        "type": "boolean"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  {
                                    "type": "object",
                                    "propertyNames": {
                                      "type": "string"
                                    },
                                    "additionalProperties": {}
                                  },
                                  {
                                    "type": "array",
                                    "items": {}
                                  }
                                ]
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "documentMetadata": {
                            "anyOf": [
                              {
                                "anyOf": [
                                  {
                                    "anyOf": [
                                      {
                                        "type": "string"
                                      },
                                      {
                                        "type": "number"
                                      },
                                      {
                                        "type": "boolean"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  {
                                    "type": "object",
                                    "propertyNames": {
                                      "type": "string"
                                    },
                                    "additionalProperties": {}
                                  },
                                  {
                                    "type": "array",
                                    "items": {}
                                  }
                                ]
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "faqMetadata": {
                            "anyOf": [
                              {
                                "anyOf": [
                                  {
                                    "anyOf": [
                                      {
                                        "type": "string"
                                      },
                                      {
                                        "type": "number"
                                      },
                                      {
                                        "type": "boolean"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  {
                                    "type": "object",
                                    "propertyNames": {
                                      "type": "string"
                                    },
                                    "additionalProperties": {}
                                  },
                                  {
                                    "type": "array",
                                    "items": {}
                                  }
                                ]
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "customMetadata": {
                            "anyOf": [
                              {
                                "anyOf": [
                                  {
                                    "anyOf": [
                                      {
                                        "type": "string"
                                      },
                                      {
                                        "type": "number"
                                      },
                                      {
                                        "type": "boolean"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  {
                                    "type": "object",
                                    "propertyNames": {
                                      "type": "string"
                                    },
                                    "additionalProperties": {}
                                  },
                                  {
                                    "type": "array",
                                    "items": {}
                                  }
                                ]
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "sourceId": {
                            "type": "string"
                          },
                          "createdAt": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "id",
                          "title",
                          "content",
                          "contentType",
                          "chunkIndex",
                          "metadata",
                          "importance",
                          "questionsAnswered",
                          "topics",
                          "keywords",
                          "webpageMetadata",
                          "documentMetadata",
                          "faqMetadata",
                          "customMetadata",
                          "sourceId",
                          "createdAt"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "sources": {
                      "type": "object",
                      "propertyNames": {
                        "type": "string"
                      },
                      "additionalProperties": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "config": {
                            "type": "object",
                            "propertyNames": {
                              "type": "string"
                            },
                            "additionalProperties": {}
                          },
                          "status": {
                            "type": "string",
                            "enum": ["pending", "processing", "ready", "error"]
                          }
                        },
                        "required": ["id", "name", "config", "status"],
                        "additionalProperties": false
                      }
                    },
                    "total": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991
                    },
                    "hasMore": {
                      "type": "boolean"
                    }
                  },
                  "required": ["chunks", "sources", "total", "hasMore"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/knowledge/sources/{id}/retry": {
      "post": {
        "operationId": "knowledge-retry",
        "summary": "Retry processing a failed knowledge source",
        "tags": ["Knowledge"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  }
                },
                "required": ["orgId"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "orgId": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "config": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "faq"
                            },
                            "pairs": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "question": {
                                    "type": "string"
                                  },
                                  "answer": {
                                    "type": "string"
                                  },
                                  "category": {
                                    "type": "string"
                                  }
                                },
                                "required": ["question", "answer"],
                                "additionalProperties": false
                              }
                            }
                          },
                          "required": ["type", "pairs"],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "document"
                            },
                            "fileKey": {
                              "type": "string"
                            },
                            "fileName": {
                              "type": "string"
                            },
                            "mimeType": {
                              "type": "string"
                            },
                            "fileSize": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991
                            },
                            "chunkSize": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991
                            },
                            "chunkOverlap": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991
                            }
                          },
                          "required": [
                            "type",
                            "fileKey",
                            "fileName",
                            "mimeType",
                            "chunkSize",
                            "chunkOverlap"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "webpage"
                            },
                            "url": {
                              "type": "string"
                            },
                            "refreshIntervalHours": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991
                            },
                            "selector": {
                              "type": "string"
                            },
                            "excludeSelectors": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "crawl": {
                              "type": "boolean"
                            },
                            "maxDepth": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991
                            },
                            "maxPages": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991
                            },
                            "crawlInstructions": {
                              "type": "string"
                            }
                          },
                          "required": ["type", "url", "refreshIntervalHours"],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "const": "custom"
                            },
                            "content": {
                              "type": "string"
                            },
                            "title": {
                              "type": "string"
                            }
                          },
                          "required": ["type", "content"],
                          "additionalProperties": false
                        }
                      ]
                    },
                    "status": {
                      "type": "string",
                      "enum": ["pending", "processing", "ready", "error"]
                    },
                    "errorMessage": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "chunkCount": {
                      "type": "integer",
                      "minimum": -2147483648,
                      "maximum": 2147483647
                    },
                    "lastSyncedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "createdAt": {
                      "type": "string"
                    },
                    "updatedAt": {
                      "type": "string"
                    },
                    "deletedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": [
                    "id",
                    "orgId",
                    "name",
                    "config",
                    "status",
                    "errorMessage",
                    "chunkCount",
                    "lastSyncedAt",
                    "createdAt",
                    "updatedAt",
                    "deletedAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/phone-numbers/configured": {
      "get": {
        "operationId": "phoneNumbers-isConfigured",
        "summary": "Check if Twilio is configured for an org",
        "tags": ["Phone Numbers"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "configured": {
                      "type": "boolean"
                    }
                  },
                  "required": ["configured"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/phone-numbers/owned": {
      "get": {
        "operationId": "phoneNumbers-listOwned",
        "summary": "List org phone numbers from local DB",
        "tags": ["Phone Numbers"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "numbers": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "orgId": {
                            "type": "string"
                          },
                          "sid": {
                            "type": "string"
                          },
                          "phoneNumber": {
                            "type": "string"
                          },
                          "friendlyName": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "capabilities": {
                            "default": {
                              "voice": false,
                              "sms": false,
                              "mms": false
                            },
                            "type": "object",
                            "properties": {
                              "voice": {
                                "type": "boolean"
                              },
                              "sms": {
                                "type": "boolean"
                              },
                              "mms": {
                                "type": "boolean"
                              }
                            },
                            "required": ["voice", "sms", "mms"],
                            "additionalProperties": false
                          },
                          "status": {
                            "type": "string"
                          },
                          "provider": {
                            "type": "string"
                          },
                          "isOrgAccount": {
                            "type": "boolean"
                          },
                          "smsRegistrationStatus": {
                            "default": "none",
                            "type": "string",
                            "enum": ["none", "pending", "approved"]
                          },
                          "lastSyncedAt": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "createdBy": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "createdAt": {
                            "type": "string"
                          },
                          "updatedAt": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "id",
                          "orgId",
                          "sid",
                          "phoneNumber",
                          "friendlyName",
                          "capabilities",
                          "status",
                          "provider",
                          "isOrgAccount",
                          "smsRegistrationStatus",
                          "lastSyncedAt",
                          "createdBy",
                          "createdAt",
                          "updatedAt"
                        ],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": ["numbers"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/phone-numbers/available": {
      "get": {
        "operationId": "phoneNumbers-listAvailable",
        "summary": "List available phone numbers for purchase",
        "tags": ["Phone Numbers"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "country",
            "schema": {
              "type": "string",
              "minLength": 2,
              "maxLength": 2
            },
            "required": true
          },
          {
            "in": "query",
            "name": "areaCode",
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "contains",
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "type",
            "schema": {
              "default": "local",
              "type": "string",
              "enum": ["local", "mobile", "toll-free"]
            }
          },
          {
            "in": "query",
            "name": "limit",
            "schema": {
              "default": 20,
              "type": "integer",
              "minimum": 1,
              "maximum": 50
            }
          },
          {
            "in": "query",
            "name": "smsEnabled",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "in": "query",
            "name": "mmsEnabled",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "in": "query",
            "name": "voiceEnabled",
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "numbers": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "phoneNumber": {
                            "type": "string"
                          },
                          "friendlyName": {
                            "type": "string"
                          },
                          "locality": {
                            "type": "string"
                          },
                          "region": {
                            "type": "string"
                          },
                          "country": {
                            "type": "string"
                          },
                          "capabilities": {
                            "type": "object",
                            "properties": {
                              "voice": {
                                "type": "boolean"
                              },
                              "sms": {
                                "type": "boolean"
                              },
                              "mms": {
                                "type": "boolean"
                              }
                            },
                            "required": ["voice", "sms", "mms"],
                            "additionalProperties": false
                          },
                          "addressRequirements": {
                            "type": "string"
                          }
                        },
                        "required": ["phoneNumber", "friendlyName", "country", "capabilities"],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": ["numbers"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/phone-numbers/twilio-account": {
      "get": {
        "operationId": "phoneNumbers-listTwilioAccount",
        "summary": "List all numbers in the Twilio account with assignment status",
        "tags": ["Phone Numbers"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "numbers": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "propertyNames": {
                          "type": "string"
                        },
                        "additionalProperties": {}
                      }
                    },
                    "isOrgAccount": {
                      "type": "boolean"
                    }
                  },
                  "required": ["numbers", "isOrgAccount"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/phone-numbers/purchase": {
      "post": {
        "operationId": "phoneNumbers-purchase",
        "summary": "Purchase a phone number and save to local DB",
        "tags": ["Phone Numbers"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "phoneNumber": {
                    "type": "string"
                  },
                  "friendlyName": {
                    "type": "string"
                  },
                  "country": {
                    "type": "string",
                    "minLength": 2,
                    "maxLength": 2
                  },
                  "numberType": {
                    "type": "string",
                    "enum": ["local", "mobile", "tollFree", "national"]
                  },
                  "bundleSid": {
                    "type": "string"
                  },
                  "addressSid": {
                    "type": "string"
                  }
                },
                "required": ["orgId", "phoneNumber"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "orgId": {
                      "type": "string"
                    },
                    "sid": {
                      "type": "string"
                    },
                    "phoneNumber": {
                      "type": "string"
                    },
                    "friendlyName": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "capabilities": {
                      "default": {
                        "voice": false,
                        "sms": false,
                        "mms": false
                      },
                      "type": "object",
                      "properties": {
                        "voice": {
                          "type": "boolean"
                        },
                        "sms": {
                          "type": "boolean"
                        },
                        "mms": {
                          "type": "boolean"
                        }
                      },
                      "required": ["voice", "sms", "mms"],
                      "additionalProperties": false
                    },
                    "status": {
                      "type": "string"
                    },
                    "provider": {
                      "type": "string"
                    },
                    "isOrgAccount": {
                      "type": "boolean"
                    },
                    "smsRegistrationStatus": {
                      "default": "none",
                      "type": "string",
                      "enum": ["none", "pending", "approved"]
                    },
                    "lastSyncedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "createdBy": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "createdAt": {
                      "type": "string"
                    },
                    "updatedAt": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "id",
                    "orgId",
                    "sid",
                    "phoneNumber",
                    "friendlyName",
                    "capabilities",
                    "status",
                    "provider",
                    "isOrgAccount",
                    "smsRegistrationStatus",
                    "lastSyncedAt",
                    "createdBy",
                    "createdAt",
                    "updatedAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/phone-numbers/assign": {
      "post": {
        "operationId": "phoneNumbers-assign",
        "summary": "Assign an existing Twilio number to this org",
        "tags": ["Phone Numbers"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "sid": {
                    "type": "string"
                  },
                  "phoneNumber": {
                    "type": "string"
                  },
                  "friendlyName": {
                    "type": "string"
                  }
                },
                "required": ["orgId", "sid", "phoneNumber"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "orgId": {
                      "type": "string"
                    },
                    "sid": {
                      "type": "string"
                    },
                    "phoneNumber": {
                      "type": "string"
                    },
                    "friendlyName": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "capabilities": {
                      "default": {
                        "voice": false,
                        "sms": false,
                        "mms": false
                      },
                      "type": "object",
                      "properties": {
                        "voice": {
                          "type": "boolean"
                        },
                        "sms": {
                          "type": "boolean"
                        },
                        "mms": {
                          "type": "boolean"
                        }
                      },
                      "required": ["voice", "sms", "mms"],
                      "additionalProperties": false
                    },
                    "status": {
                      "type": "string"
                    },
                    "provider": {
                      "type": "string"
                    },
                    "isOrgAccount": {
                      "type": "boolean"
                    },
                    "smsRegistrationStatus": {
                      "default": "none",
                      "type": "string",
                      "enum": ["none", "pending", "approved"]
                    },
                    "lastSyncedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "createdBy": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "createdAt": {
                      "type": "string"
                    },
                    "updatedAt": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "id",
                    "orgId",
                    "sid",
                    "phoneNumber",
                    "friendlyName",
                    "capabilities",
                    "status",
                    "provider",
                    "isOrgAccount",
                    "smsRegistrationStatus",
                    "lastSyncedAt",
                    "createdBy",
                    "createdAt",
                    "updatedAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/phone-numbers/{sid}/sync": {
      "post": {
        "operationId": "phoneNumbers-syncWebhooks",
        "summary": "Sync phone number webhooks with default API endpoints",
        "tags": ["Phone Numbers"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "sid",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  }
                },
                "required": ["orgId"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "webhooks": {
                      "type": "object",
                      "properties": {
                        "voice": {
                          "type": "string"
                        },
                        "sms": {
                          "type": "string"
                        }
                      },
                      "required": ["voice", "sms"],
                      "additionalProperties": false
                    }
                  },
                  "required": ["success", "webhooks"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/phone-numbers/sync-all": {
      "post": {
        "operationId": "phoneNumbers-syncAllWebhooks",
        "summary": "Re-sync all numbers' webhooks to region-scoped URLs",
        "tags": ["Phone Numbers"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  }
                },
                "required": ["orgId"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "synced": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991
                    },
                    "failed": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991
                    }
                  },
                  "required": ["synced", "failed"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/phone-numbers/{sid}": {
      "delete": {
        "operationId": "phoneNumbers-release",
        "summary": "Release a phone number",
        "tags": ["Phone Numbers"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "sid",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    }
                  },
                  "required": ["success"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/phone-numbers/webhook-urls": {
      "get": {
        "operationId": "phoneNumbers-getWebhookUrls",
        "summary": "Get default webhook URLs",
        "tags": ["Phone Numbers"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "voice": {
                      "type": "string"
                    },
                    "sms": {
                      "type": "string"
                    }
                  },
                  "required": ["voice", "sms"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/regulatory-bundles": {
      "get": {
        "operationId": "regulatoryBundles-list",
        "summary": "List the org's cached Twilio regulatory bundle statuses",
        "tags": ["Regulatory Bundles"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "bundles": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "orgId": {
                            "type": "string"
                          },
                          "isoCountry": {
                            "type": "string"
                          },
                          "numberType": {
                            "type": "string"
                          },
                          "bundleSid": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "addressSid": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "endUserSid": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "regulationSid": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "status": {
                            "default": "not_created",
                            "type": "string",
                            "enum": [
                              "not_created",
                              "draft",
                              "pending_review",
                              "in_review",
                              "twilio_approved",
                              "twilio_rejected",
                              "provisionally_approved"
                            ]
                          },
                          "friendlyName": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "requirementsJson": {
                            "anyOf": [
                              {
                                "default": null,
                                "anyOf": [
                                  {
                                    "type": "object",
                                    "properties": {
                                      "regulationSid": {
                                        "type": "string"
                                      },
                                      "endUserType": {
                                        "type": "string"
                                      },
                                      "friendlyName": {
                                        "type": "string"
                                      },
                                      "endUserFields": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "name": {
                                              "type": "string"
                                            },
                                            "friendlyName": {
                                              "type": "string"
                                            },
                                            "type": {
                                              "type": "string"
                                            }
                                          },
                                          "required": ["name"],
                                          "additionalProperties": false
                                        }
                                      },
                                      "requiredDocuments": {
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "type": {
                                              "type": "string"
                                            },
                                            "friendlyName": {
                                              "type": "string"
                                            }
                                          },
                                          "required": ["type"],
                                          "additionalProperties": false
                                        }
                                      }
                                    },
                                    "required": [
                                      "regulationSid",
                                      "endUserType",
                                      "friendlyName",
                                      "endUserFields",
                                      "requiredDocuments"
                                    ],
                                    "additionalProperties": false
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "lastSyncedAt": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "submittedAt": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "reviewedAt": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "rejectionReason": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "createdAt": {
                            "type": "string"
                          },
                          "updatedAt": {
                            "type": "string"
                          },
                          "deletedAt": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        },
                        "required": [
                          "id",
                          "orgId",
                          "isoCountry",
                          "numberType",
                          "bundleSid",
                          "addressSid",
                          "endUserSid",
                          "regulationSid",
                          "status",
                          "friendlyName",
                          "requirementsJson",
                          "lastSyncedAt",
                          "submittedAt",
                          "reviewedAt",
                          "rejectionReason",
                          "createdAt",
                          "updatedAt",
                          "deletedAt"
                        ],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": ["bundles"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/regulatory-bundles/refresh": {
      "post": {
        "operationId": "regulatoryBundles-refresh",
        "summary": "Sync a regulatory bundle status from Twilio for a country/number type",
        "tags": ["Regulatory Bundles"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "isoCountry": {
                    "type": "string",
                    "minLength": 2,
                    "maxLength": 2
                  },
                  "numberType": {
                    "type": "string",
                    "enum": ["local", "mobile", "national", "tollFree"]
                  }
                },
                "required": ["orgId", "isoCountry", "numberType"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "orgId": {
                      "type": "string"
                    },
                    "isoCountry": {
                      "type": "string"
                    },
                    "numberType": {
                      "type": "string"
                    },
                    "bundleSid": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "addressSid": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "endUserSid": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "regulationSid": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "status": {
                      "default": "not_created",
                      "type": "string",
                      "enum": [
                        "not_created",
                        "draft",
                        "pending_review",
                        "in_review",
                        "twilio_approved",
                        "twilio_rejected",
                        "provisionally_approved"
                      ]
                    },
                    "friendlyName": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "requirementsJson": {
                      "anyOf": [
                        {
                          "default": null,
                          "anyOf": [
                            {
                              "type": "object",
                              "properties": {
                                "regulationSid": {
                                  "type": "string"
                                },
                                "endUserType": {
                                  "type": "string"
                                },
                                "friendlyName": {
                                  "type": "string"
                                },
                                "endUserFields": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "name": {
                                        "type": "string"
                                      },
                                      "friendlyName": {
                                        "type": "string"
                                      },
                                      "type": {
                                        "type": "string"
                                      }
                                    },
                                    "required": ["name"],
                                    "additionalProperties": false
                                  }
                                },
                                "requiredDocuments": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "type": {
                                        "type": "string"
                                      },
                                      "friendlyName": {
                                        "type": "string"
                                      }
                                    },
                                    "required": ["type"],
                                    "additionalProperties": false
                                  }
                                }
                              },
                              "required": [
                                "regulationSid",
                                "endUserType",
                                "friendlyName",
                                "endUserFields",
                                "requiredDocuments"
                              ],
                              "additionalProperties": false
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "lastSyncedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "submittedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "reviewedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "rejectionReason": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "createdAt": {
                      "type": "string"
                    },
                    "updatedAt": {
                      "type": "string"
                    },
                    "deletedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": [
                    "id",
                    "orgId",
                    "isoCountry",
                    "numberType",
                    "bundleSid",
                    "addressSid",
                    "endUserSid",
                    "regulationSid",
                    "status",
                    "friendlyName",
                    "requirementsJson",
                    "lastSyncedAt",
                    "submittedAt",
                    "reviewedAt",
                    "rejectionReason",
                    "createdAt",
                    "updatedAt",
                    "deletedAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/regulatory-bundles/requirements": {
      "post": {
        "operationId": "regulatoryBundles-requirements",
        "summary": "Fetch the dynamic identity requirements for a country/number type",
        "tags": ["Regulatory Bundles"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "isoCountry": {
                    "type": "string",
                    "minLength": 2,
                    "maxLength": 2
                  },
                  "numberType": {
                    "type": "string",
                    "enum": ["local", "mobile", "national", "tollFree"]
                  },
                  "endUserType": {
                    "type": "string",
                    "enum": ["business", "individual"]
                  }
                },
                "required": ["orgId", "isoCountry", "numberType"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "regulationSid": {
                      "type": "string"
                    },
                    "endUserType": {
                      "type": "string"
                    },
                    "friendlyName": {
                      "type": "string"
                    },
                    "endUserFields": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "name": {
                            "type": "string"
                          },
                          "friendlyName": {
                            "type": "string"
                          },
                          "type": {
                            "type": "string"
                          }
                        },
                        "required": ["name"],
                        "additionalProperties": false
                      }
                    },
                    "requiredDocuments": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "friendlyName": {
                            "type": "string"
                          }
                        },
                        "required": ["type"],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": [
                    "regulationSid",
                    "endUserType",
                    "friendlyName",
                    "endUserFields",
                    "requiredDocuments"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/regulatory-bundles/create": {
      "post": {
        "operationId": "regulatoryBundles-create",
        "summary": "Create a draft regulatory bundle (identity + address) for the org",
        "tags": ["Regulatory Bundles"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "isoCountry": {
                    "type": "string",
                    "minLength": 2,
                    "maxLength": 2
                  },
                  "numberType": {
                    "type": "string",
                    "enum": ["local", "mobile", "national", "tollFree"]
                  },
                  "regulationSid": {
                    "type": "string"
                  },
                  "endUserType": {
                    "type": "string",
                    "enum": ["business", "individual"]
                  },
                  "friendlyName": {
                    "type": "string",
                    "maxLength": 255
                  },
                  "email": {
                    "type": "string",
                    "format": "email",
                    "pattern": "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
                  },
                  "attributes": {
                    "type": "object",
                    "propertyNames": {
                      "type": "string"
                    },
                    "additionalProperties": {}
                  },
                  "address": {
                    "type": "object",
                    "properties": {
                      "customerName": {
                        "type": "string",
                        "minLength": 1
                      },
                      "street": {
                        "type": "string",
                        "minLength": 1
                      },
                      "city": {
                        "type": "string",
                        "minLength": 1
                      },
                      "region": {
                        "type": "string"
                      },
                      "postalCode": {
                        "type": "string",
                        "minLength": 1
                      },
                      "isoCountry": {
                        "type": "string",
                        "minLength": 2,
                        "maxLength": 2
                      }
                    },
                    "required": ["customerName", "street", "city", "postalCode", "isoCountry"]
                  }
                },
                "required": [
                  "orgId",
                  "isoCountry",
                  "numberType",
                  "regulationSid",
                  "endUserType",
                  "attributes",
                  "address"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "orgId": {
                      "type": "string"
                    },
                    "isoCountry": {
                      "type": "string"
                    },
                    "numberType": {
                      "type": "string"
                    },
                    "bundleSid": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "addressSid": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "endUserSid": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "regulationSid": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "status": {
                      "default": "not_created",
                      "type": "string",
                      "enum": [
                        "not_created",
                        "draft",
                        "pending_review",
                        "in_review",
                        "twilio_approved",
                        "twilio_rejected",
                        "provisionally_approved"
                      ]
                    },
                    "friendlyName": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "requirementsJson": {
                      "anyOf": [
                        {
                          "default": null,
                          "anyOf": [
                            {
                              "type": "object",
                              "properties": {
                                "regulationSid": {
                                  "type": "string"
                                },
                                "endUserType": {
                                  "type": "string"
                                },
                                "friendlyName": {
                                  "type": "string"
                                },
                                "endUserFields": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "name": {
                                        "type": "string"
                                      },
                                      "friendlyName": {
                                        "type": "string"
                                      },
                                      "type": {
                                        "type": "string"
                                      }
                                    },
                                    "required": ["name"],
                                    "additionalProperties": false
                                  }
                                },
                                "requiredDocuments": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "type": {
                                        "type": "string"
                                      },
                                      "friendlyName": {
                                        "type": "string"
                                      }
                                    },
                                    "required": ["type"],
                                    "additionalProperties": false
                                  }
                                }
                              },
                              "required": [
                                "regulationSid",
                                "endUserType",
                                "friendlyName",
                                "endUserFields",
                                "requiredDocuments"
                              ],
                              "additionalProperties": false
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "lastSyncedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "submittedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "reviewedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "rejectionReason": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "createdAt": {
                      "type": "string"
                    },
                    "updatedAt": {
                      "type": "string"
                    },
                    "deletedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": [
                    "id",
                    "orgId",
                    "isoCountry",
                    "numberType",
                    "bundleSid",
                    "addressSid",
                    "endUserSid",
                    "regulationSid",
                    "status",
                    "friendlyName",
                    "requirementsJson",
                    "lastSyncedAt",
                    "submittedAt",
                    "reviewedAt",
                    "rejectionReason",
                    "createdAt",
                    "updatedAt",
                    "deletedAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/regulatory-bundles/submit": {
      "post": {
        "operationId": "regulatoryBundles-submit",
        "summary": "Submit the org's regulatory bundle for review",
        "tags": ["Regulatory Bundles"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "isoCountry": {
                    "type": "string",
                    "minLength": 2,
                    "maxLength": 2
                  },
                  "numberType": {
                    "type": "string",
                    "enum": ["local", "mobile", "national", "tollFree"]
                  }
                },
                "required": ["orgId", "isoCountry", "numberType"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "orgId": {
                      "type": "string"
                    },
                    "isoCountry": {
                      "type": "string"
                    },
                    "numberType": {
                      "type": "string"
                    },
                    "bundleSid": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "addressSid": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "endUserSid": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "regulationSid": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "status": {
                      "default": "not_created",
                      "type": "string",
                      "enum": [
                        "not_created",
                        "draft",
                        "pending_review",
                        "in_review",
                        "twilio_approved",
                        "twilio_rejected",
                        "provisionally_approved"
                      ]
                    },
                    "friendlyName": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "requirementsJson": {
                      "anyOf": [
                        {
                          "default": null,
                          "anyOf": [
                            {
                              "type": "object",
                              "properties": {
                                "regulationSid": {
                                  "type": "string"
                                },
                                "endUserType": {
                                  "type": "string"
                                },
                                "friendlyName": {
                                  "type": "string"
                                },
                                "endUserFields": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "name": {
                                        "type": "string"
                                      },
                                      "friendlyName": {
                                        "type": "string"
                                      },
                                      "type": {
                                        "type": "string"
                                      }
                                    },
                                    "required": ["name"],
                                    "additionalProperties": false
                                  }
                                },
                                "requiredDocuments": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "type": {
                                        "type": "string"
                                      },
                                      "friendlyName": {
                                        "type": "string"
                                      }
                                    },
                                    "required": ["type"],
                                    "additionalProperties": false
                                  }
                                }
                              },
                              "required": [
                                "regulationSid",
                                "endUserType",
                                "friendlyName",
                                "endUserFields",
                                "requiredDocuments"
                              ],
                              "additionalProperties": false
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "lastSyncedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "submittedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "reviewedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "rejectionReason": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "createdAt": {
                      "type": "string"
                    },
                    "updatedAt": {
                      "type": "string"
                    },
                    "deletedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": [
                    "id",
                    "orgId",
                    "isoCountry",
                    "numberType",
                    "bundleSid",
                    "addressSid",
                    "endUserSid",
                    "regulationSid",
                    "status",
                    "friendlyName",
                    "requirementsJson",
                    "lastSyncedAt",
                    "submittedAt",
                    "reviewedAt",
                    "rejectionReason",
                    "createdAt",
                    "updatedAt",
                    "deletedAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/regulatory-bundles/org-prefill": {
      "get": {
        "operationId": "regulatoryBundles-getOrgPrefill",
        "summary": "Get prefill data for bundle creation from the org business profile",
        "tags": ["Regulatory Bundles"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "customerName": {
                      "type": "string"
                    },
                    "address": {
                      "type": "object",
                      "properties": {
                        "street": {
                          "type": "string"
                        },
                        "city": {
                          "type": "string"
                        },
                        "region": {
                          "type": "string"
                        },
                        "postalCode": {
                          "type": "string"
                        },
                        "isoCountry": {
                          "type": "string",
                          "minLength": 2,
                          "maxLength": 2
                        }
                      },
                      "additionalProperties": false
                    },
                    "email": {
                      "type": "string",
                      "format": "email",
                      "pattern": "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
                    }
                  },
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/voices/configured": {
      "get": {
        "operationId": "voices-isConfigured",
        "summary": "Check if ElevenLabs is configured",
        "tags": ["Voices"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "configured": {
                      "type": "boolean"
                    }
                  },
                  "required": ["configured"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/voices": {
      "get": {
        "operationId": "voices-list",
        "summary": "List available voices",
        "tags": ["Voices"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "language",
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "accent",
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "gender",
            "schema": {
              "type": "string",
              "enum": ["male", "female"]
            }
          },
          {
            "in": "query",
            "name": "age",
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "search",
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "showLegacy",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "in": "query",
            "name": "includeShared",
            "schema": {
              "default": true,
              "type": "boolean"
            }
          },
          {
            "in": "query",
            "name": "onlyShared",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "in": "query",
            "name": "sort",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "voices": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "category": {
                            "type": "string"
                          },
                          "description": {
                            "type": "string"
                          },
                          "previewUrl": {
                            "type": "string"
                          },
                          "gender": {
                            "type": "string"
                          },
                          "accent": {
                            "type": "string"
                          },
                          "age": {
                            "type": "string"
                          },
                          "useCase": {
                            "type": "string"
                          },
                          "conversational": {
                            "type": "boolean"
                          },
                          "publicOwnerId": {
                            "type": "string"
                          },
                          "isShared": {
                            "type": "boolean"
                          }
                        },
                        "required": ["id", "name", "category"],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": ["voices"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/voices/agents": {
      "get": {
        "operationId": "voices-listAgents",
        "summary": "List ElevenLabs conversational AI agents",
        "tags": ["Voices"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "agents": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "agent_id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          }
                        },
                        "required": ["agent_id", "name"],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": ["agents"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/voice-calls/{conversationId}": {
      "get": {
        "operationId": "voiceCalls-getByConversation",
        "summary": "Get voice call metadata for a conversation",
        "tags": ["Voice"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "conversationId",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "orgId": {
                          "type": "string"
                        },
                        "conversationId": {
                          "type": "string"
                        },
                        "direction": {
                          "default": "inbound",
                          "type": "string",
                          "enum": ["inbound", "outbound"]
                        },
                        "fromNumber": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "toNumber": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "twilioCallSid": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "elevenLabsConversationId": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "status": {
                          "default": "in_progress",
                          "type": "string",
                          "enum": [
                            "queued",
                            "ringing",
                            "in_progress",
                            "completed",
                            "busy",
                            "no_answer",
                            "failed",
                            "canceled"
                          ]
                        },
                        "endReason": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "startedAt": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "endedAt": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "durationSeconds": {
                          "anyOf": [
                            {
                              "type": "integer",
                              "minimum": -2147483648,
                              "maximum": 2147483647
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "recordingDurationSeconds": {
                          "anyOf": [
                            {
                              "type": "integer",
                              "minimum": -2147483648,
                              "maximum": 2147483647
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "callSuccessful": {
                          "anyOf": [
                            {
                              "type": "boolean"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "summary": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "cost": {
                          "anyOf": [
                            {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "outcome": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "createdAt": {
                          "type": "string"
                        },
                        "updatedAt": {
                          "type": "string"
                        },
                        "hasRecording": {
                          "type": "boolean"
                        }
                      },
                      "required": [
                        "id",
                        "orgId",
                        "conversationId",
                        "direction",
                        "fromNumber",
                        "toNumber",
                        "twilioCallSid",
                        "elevenLabsConversationId",
                        "status",
                        "endReason",
                        "startedAt",
                        "endedAt",
                        "durationSeconds",
                        "recordingDurationSeconds",
                        "callSuccessful",
                        "summary",
                        "cost",
                        "outcome",
                        "createdAt",
                        "updatedAt",
                        "hasRecording"
                      ],
                      "additionalProperties": false
                    },
                    {
                      "type": "null"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/credentials": {
      "get": {
        "operationId": "providerCredentials-list",
        "summary": "List organization provider credentials",
        "tags": ["Provider Credentials"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "credentials": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "provider": {
                            "type": "string"
                          },
                          "name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "isActive": {
                            "type": "boolean"
                          },
                          "validationStatus": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "lastValidated": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "createdAt": {
                            "type": "string"
                          },
                          "updatedAt": {
                            "type": "string"
                          },
                          "maskedCredentials": {
                            "anyOf": [
                              {
                                "type": "object",
                                "propertyNames": {
                                  "type": "string"
                                },
                                "additionalProperties": {}
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        },
                        "required": [
                          "id",
                          "provider",
                          "name",
                          "isActive",
                          "validationStatus",
                          "lastValidated",
                          "createdAt",
                          "updatedAt",
                          "maskedCredentials"
                        ],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": ["credentials"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "providerCredentials-create",
        "summary": "Create provider credential",
        "tags": ["Provider Credentials"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "provider": {
                    "type": "string",
                    "enum": ["twilio", "elevenlabs", "meta", "gmail", "microsoft"]
                  },
                  "name": {
                    "type": "string"
                  },
                  "credentials": {
                    "anyOf": [
                      {
                        "type": "object",
                        "properties": {
                          "accountSid": {
                            "type": "string",
                            "minLength": 1
                          },
                          "authToken": {
                            "type": "string",
                            "minLength": 1
                          }
                        },
                        "required": ["accountSid", "authToken"]
                      },
                      {
                        "type": "object",
                        "properties": {
                          "apiKey": {
                            "type": "string",
                            "minLength": 1
                          }
                        },
                        "required": ["apiKey"]
                      }
                    ]
                  }
                },
                "required": ["orgId", "provider", "credentials"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "provider": {
                      "type": "string"
                    },
                    "name": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "isActive": {
                      "type": "boolean"
                    },
                    "validationStatus": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "createdAt": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "id",
                    "provider",
                    "name",
                    "isActive",
                    "validationStatus",
                    "createdAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/credentials/{id}": {
      "patch": {
        "operationId": "providerCredentials-update",
        "summary": "Update provider credential",
        "tags": ["Provider Credentials"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string"
                  },
                  "isActive": {
                    "type": "boolean"
                  }
                },
                "required": ["orgId"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "provider": {
                      "type": "string"
                    },
                    "name": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "isActive": {
                      "type": "boolean"
                    },
                    "validationStatus": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "updatedAt": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "id",
                    "provider",
                    "name",
                    "isActive",
                    "validationStatus",
                    "updatedAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "providerCredentials-delete",
        "summary": "Delete provider credential",
        "tags": ["Provider Credentials"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    }
                  },
                  "required": ["success"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/credentials/{id}/validate": {
      "post": {
        "operationId": "providerCredentials-validate",
        "summary": "Validate provider credential",
        "tags": ["Provider Credentials"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  }
                },
                "required": ["orgId"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "valid": {
                      "type": "boolean"
                    },
                    "error": {
                      "type": "string"
                    },
                    "validationStatus": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "lastValidated": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": ["valid", "validationStatus", "lastValidated"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/credentials/status/{provider}": {
      "get": {
        "operationId": "providerCredentials-getProviderStatus",
        "summary": "Get provider configuration status",
        "tags": ["Provider Credentials"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "provider",
            "schema": {
              "type": "string",
              "enum": ["twilio", "elevenlabs", "meta", "gmail", "microsoft"]
            },
            "required": true
          },
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "provider": {
                      "type": "string"
                    },
                    "hasOrgCredential": {
                      "type": "boolean"
                    },
                    "orgCredentialId": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "orgCredentialName": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "orgCredentialStatus": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "hasGlobalCredential": {
                      "type": "boolean"
                    },
                    "isConfigured": {
                      "type": "boolean"
                    },
                    "source": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": ["organization", "global"]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": [
                    "provider",
                    "hasOrgCredential",
                    "orgCredentialId",
                    "orgCredentialName",
                    "orgCredentialStatus",
                    "hasGlobalCredential",
                    "isConfigured",
                    "source"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/webhooks/event-types": {
      "get": {
        "operationId": "webhooks-eventTypes",
        "summary": "List available webhook event types",
        "tags": ["Webhooks"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "eventTypes": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "key": {
                            "type": "string"
                          },
                          "label": {
                            "type": "string"
                          },
                          "category": {
                            "type": "string"
                          }
                        },
                        "required": ["key", "label", "category"],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": ["eventTypes"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/webhooks": {
      "get": {
        "operationId": "webhooks-list",
        "summary": "List organization webhooks",
        "tags": ["Webhooks"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "webhooks": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "slug": {
                            "type": "string"
                          },
                          "url": {
                            "type": "string"
                          },
                          "events": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "status": {
                            "type": "string"
                          },
                          "lastHealthCheck": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "errorCount": {
                            "type": "number"
                          },
                          "lastError": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "config": {
                            "type": "object",
                            "propertyNames": {
                              "type": "string"
                            },
                            "additionalProperties": {}
                          },
                          "createdAt": {
                            "type": "string"
                          },
                          "updatedAt": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "id",
                          "name",
                          "slug",
                          "url",
                          "events",
                          "status",
                          "lastHealthCheck",
                          "errorCount",
                          "lastError",
                          "config",
                          "createdAt",
                          "updatedAt"
                        ],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": ["webhooks"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "webhooks-create",
        "summary": "Create a new webhook",
        "tags": ["Webhooks"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string",
                    "minLength": 1
                  },
                  "url": {
                    "type": "string",
                    "format": "uri"
                  },
                  "events": {
                    "minItems": 1,
                    "type": "array",
                    "items": {
                      "type": "string",
                      "enum": [
                        "call.completed",
                        "outbound.request.completed",
                        "outbound.callback.scheduled",
                        "outbound.campaign.paused",
                        "conversation.created",
                        "conversation.updated",
                        "conversation.closed",
                        "conversation.assigned",
                        "message.received",
                        "message.sent",
                        "message.failed",
                        "contact.created",
                        "contact.updated",
                        "escalation.created",
                        "escalation.resolved",
                        "ai.turn.completed"
                      ]
                    }
                  },
                  "description": {
                    "type": "string"
                  }
                },
                "required": ["orgId", "name", "url", "events"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "slug": {
                      "type": "string"
                    },
                    "url": {
                      "type": "string"
                    },
                    "events": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "status": {
                      "type": "string"
                    },
                    "secret": {
                      "type": "string"
                    },
                    "signingEndpoint": {
                      "type": "string"
                    },
                    "createdAt": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "id",
                    "name",
                    "slug",
                    "url",
                    "events",
                    "status",
                    "secret",
                    "signingEndpoint",
                    "createdAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/webhooks/{id}": {
      "get": {
        "operationId": "webhooks-get",
        "summary": "Get webhook details including secret",
        "tags": ["Webhooks"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "slug": {
                      "type": "string"
                    },
                    "url": {
                      "type": "string"
                    },
                    "events": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "status": {
                      "type": "string"
                    },
                    "lastHealthCheck": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "errorCount": {
                      "type": "number"
                    },
                    "lastError": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "config": {
                      "type": "object",
                      "propertyNames": {
                        "type": "string"
                      },
                      "additionalProperties": {}
                    },
                    "createdAt": {
                      "type": "string"
                    },
                    "updatedAt": {
                      "type": "string"
                    },
                    "secret": {
                      "type": "string"
                    },
                    "algorithm": {
                      "type": "string"
                    },
                    "signingEndpoint": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "id",
                    "name",
                    "slug",
                    "url",
                    "events",
                    "status",
                    "lastHealthCheck",
                    "errorCount",
                    "lastError",
                    "config",
                    "createdAt",
                    "updatedAt",
                    "secret",
                    "algorithm",
                    "signingEndpoint"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "webhooks-update",
        "summary": "Update a webhook",
        "tags": ["Webhooks"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string",
                    "minLength": 1
                  },
                  "url": {
                    "type": "string",
                    "format": "uri"
                  },
                  "events": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "enum": [
                        "call.completed",
                        "outbound.request.completed",
                        "outbound.callback.scheduled",
                        "outbound.campaign.paused",
                        "conversation.created",
                        "conversation.updated",
                        "conversation.closed",
                        "conversation.assigned",
                        "message.received",
                        "message.sent",
                        "message.failed",
                        "contact.created",
                        "contact.updated",
                        "escalation.created",
                        "escalation.resolved",
                        "ai.turn.completed"
                      ]
                    }
                  },
                  "description": {
                    "type": "string"
                  },
                  "status": {
                    "type": "string",
                    "enum": ["active", "paused"]
                  }
                },
                "required": ["orgId"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "slug": {
                      "type": "string"
                    },
                    "url": {
                      "type": "string"
                    },
                    "events": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "status": {
                      "type": "string"
                    },
                    "updatedAt": {
                      "type": "string"
                    }
                  },
                  "required": ["id", "name", "slug", "url", "events", "status", "updatedAt"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "webhooks-delete",
        "summary": "Delete a webhook",
        "tags": ["Webhooks"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    }
                  },
                  "required": ["success"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/webhooks/{id}/regenerate-secret": {
      "post": {
        "operationId": "webhooks-regenerateSecret",
        "summary": "Regenerate webhook signing secret",
        "tags": ["Webhooks"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  }
                },
                "required": ["orgId"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "secret": {
                      "type": "string"
                    },
                    "updatedAt": {
                      "type": "string"
                    }
                  },
                  "required": ["id", "secret", "updatedAt"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/webhooks/{id}/test": {
      "post": {
        "operationId": "webhooks-test",
        "summary": "Send a test event to the webhook",
        "tags": ["Webhooks"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  }
                },
                "required": ["orgId"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "statusCode": {
                      "type": "number"
                    },
                    "statusText": {
                      "type": "string"
                    },
                    "testedAt": {
                      "type": "string"
                    }
                  },
                  "required": ["success", "statusCode", "statusText", "testedAt"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/chat/message": {
      "post": {
        "operationId": "chat-sendMessage",
        "summary": "Send a chat message and get AI response",
        "tags": ["Chat Console"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "conversationId": {
                    "type": "string"
                  },
                  "operationId": {
                    "type": "string",
                    "format": "uuid",
                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                  },
                  "inboxId": {
                    "type": "string"
                  },
                  "message": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 10000
                  },
                  "channel": {
                    "default": "chat",
                    "type": "string",
                    "enum": ["voice", "sms", "whatsapp", "chat", "instagram", "google_reviews"]
                  },
                  "stream": {
                    "default": true,
                    "type": "boolean"
                  }
                },
                "required": ["orgId", "conversationId", "operationId", "message"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "userMessageId": {
                      "type": "string"
                    },
                    "aiMessageId": {
                      "type": "string"
                    },
                    "content": {
                      "type": "string"
                    },
                    "toolCalls": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "name": {
                            "type": "string"
                          },
                          "arguments": {
                            "type": "object",
                            "propertyNames": {
                              "type": "string"
                            },
                            "additionalProperties": {}
                          },
                          "result": {}
                        },
                        "required": ["name", "arguments", "result"],
                        "additionalProperties": false
                      }
                    },
                    "usage": {
                      "type": "object",
                      "properties": {
                        "inputTokens": {
                          "type": "number"
                        },
                        "outputTokens": {
                          "type": "number"
                        }
                      },
                      "required": ["inputTokens", "outputTokens"],
                      "additionalProperties": false
                    },
                    "components": {
                      "type": "object",
                      "properties": {
                        "quickReplies": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "label": {
                                "type": "string"
                              },
                              "value": {
                                "type": "string"
                              }
                            },
                            "required": ["label", "value"],
                            "additionalProperties": false
                          }
                        },
                        "card": {
                          "type": "object",
                          "properties": {
                            "title": {
                              "type": "string"
                            },
                            "subtitle": {
                              "type": "string"
                            },
                            "fields": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "label": {
                                    "type": "string"
                                  },
                                  "value": {
                                    "type": "string"
                                  }
                                },
                                "required": ["label", "value"],
                                "additionalProperties": false
                              }
                            }
                          },
                          "required": ["title"],
                          "additionalProperties": false
                        }
                      },
                      "additionalProperties": false
                    }
                  },
                  "required": ["userMessageId", "aiMessageId", "content"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/chat/session": {
      "post": {
        "operationId": "chat-createSession",
        "summary": "Create a new chat session",
        "tags": ["Chat Console"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "inboxId": {
                    "type": "string"
                  },
                  "customerInfo": {
                    "type": "object",
                    "properties": {
                      "name": {
                        "type": "string"
                      },
                      "email": {
                        "type": "string",
                        "format": "email",
                        "pattern": "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
                      },
                      "phone": {
                        "type": "string"
                      }
                    }
                  }
                },
                "required": ["orgId", "inboxId"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "conversationId": {
                      "type": "string"
                    },
                    "sessionId": {
                      "type": "string"
                    }
                  },
                  "required": ["conversationId", "sessionId"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/chat/history": {
      "get": {
        "operationId": "chat-getHistory",
        "summary": "Get chat message history",
        "tags": ["Chat Console"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "conversationId",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "limit",
            "schema": {
              "default": 50,
              "type": "integer",
              "minimum": 1,
              "maximum": 100
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "messages": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "role": {
                            "type": "string"
                          },
                          "content": {
                            "type": "string"
                          }
                        },
                        "required": ["role", "content"],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": ["messages"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/chat/voice/token": {
      "post": {
        "operationId": "chat-getVoiceToken",
        "summary": "Get ElevenLabs voice token for WebRTC",
        "tags": ["Chat Console"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "aiAgentId": {
                    "type": "string"
                  },
                  "voiceAgentId": {
                    "type": "string"
                  }
                },
                "required": ["orgId"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "signedUrl": {
                      "type": "string"
                    },
                    "agentId": {
                      "type": "string"
                    },
                    "voiceAgentName": {
                      "type": "string"
                    }
                  },
                  "required": ["signedUrl", "agentId"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/files/{id}": {
      "get": {
        "operationId": "files-get",
        "summary": "Get file metadata by ID",
        "tags": ["Files"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "orgId": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "mimeType": {
                      "type": "string"
                    },
                    "size": {
                      "type": "integer",
                      "minimum": -2147483648,
                      "maximum": 2147483647
                    },
                    "scope": {
                      "type": "string",
                      "enum": ["conversation", "knowledge", "contact", "organization"]
                    },
                    "scopeId": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "status": {
                      "type": "string",
                      "enum": ["uploading", "ready", "error"]
                    },
                    "uploadedBy": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "createdAt": {
                      "type": "string"
                    },
                    "updatedAt": {
                      "type": "string"
                    },
                    "deletedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": [
                    "id",
                    "orgId",
                    "name",
                    "mimeType",
                    "size",
                    "scope",
                    "scopeId",
                    "status",
                    "uploadedBy",
                    "createdAt",
                    "updatedAt",
                    "deletedAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "files-delete",
        "summary": "Delete a file",
        "tags": ["Files"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    }
                  },
                  "required": ["success"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/files": {
      "get": {
        "operationId": "files-list",
        "summary": "List files by org and optional scope",
        "tags": ["Files"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "scope",
            "schema": {
              "type": "string",
              "enum": ["conversation", "knowledge", "contact", "organization"]
            }
          },
          {
            "in": "query",
            "name": "scopeId",
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "limit",
            "schema": {
              "default": 50,
              "type": "integer",
              "minimum": 1,
              "maximum": 100
            }
          },
          {
            "in": "query",
            "name": "offset",
            "schema": {
              "default": 0,
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "files": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "orgId": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "mimeType": {
                            "type": "string"
                          },
                          "size": {
                            "type": "integer",
                            "minimum": -2147483648,
                            "maximum": 2147483647
                          },
                          "scope": {
                            "type": "string",
                            "enum": ["conversation", "knowledge", "contact", "organization"]
                          },
                          "scopeId": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "status": {
                            "type": "string",
                            "enum": ["uploading", "ready", "error"]
                          },
                          "uploadedBy": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "createdAt": {
                            "type": "string"
                          },
                          "updatedAt": {
                            "type": "string"
                          },
                          "deletedAt": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        },
                        "required": [
                          "id",
                          "orgId",
                          "name",
                          "mimeType",
                          "size",
                          "scope",
                          "scopeId",
                          "status",
                          "uploadedBy",
                          "createdAt",
                          "updatedAt",
                          "deletedAt"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "total": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991
                    }
                  },
                  "required": ["files", "total"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/audit-logs": {
      "get": {
        "operationId": "auditLogs-list",
        "summary": "List audit logs",
        "tags": ["Audit Logs"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "actorId",
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "action",
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "resourceType",
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "resourceId",
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "startDate",
            "schema": {
              "type": "string",
              "format": "date-time",
              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
            }
          },
          {
            "in": "query",
            "name": "endDate",
            "schema": {
              "type": "string",
              "format": "date-time",
              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
            }
          },
          {
            "in": "query",
            "name": "limit",
            "schema": {
              "default": 50,
              "type": "integer",
              "minimum": 1,
              "maximum": 100
            }
          },
          {
            "in": "query",
            "name": "offset",
            "schema": {
              "default": 0,
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "logs": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "orgId": {
                            "type": "string"
                          },
                          "actorType": {
                            "type": "string"
                          },
                          "actorId": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "action": {
                            "type": "string"
                          },
                          "resourceType": {
                            "type": "string"
                          },
                          "resourceId": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "changes": {
                            "anyOf": [
                              {
                                "anyOf": [
                                  {
                                    "type": "object",
                                    "propertyNames": {
                                      "type": "string"
                                    },
                                    "additionalProperties": {}
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "metadata": {
                            "anyOf": [
                              {
                                "anyOf": [
                                  {
                                    "type": "object",
                                    "propertyNames": {
                                      "type": "string"
                                    },
                                    "additionalProperties": {}
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "requestId": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "ipAddress": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "userAgent": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "createdAt": {
                            "type": "string"
                          },
                          "actorName": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        },
                        "required": [
                          "id",
                          "orgId",
                          "actorType",
                          "actorId",
                          "action",
                          "resourceType",
                          "resourceId",
                          "changes",
                          "metadata",
                          "requestId",
                          "ipAddress",
                          "userAgent",
                          "createdAt",
                          "actorName"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "pagination": {
                      "type": "object",
                      "properties": {
                        "total": {
                          "type": "number"
                        },
                        "limit": {
                          "type": "number"
                        },
                        "offset": {
                          "type": "number"
                        }
                      },
                      "required": ["total", "limit", "offset"],
                      "additionalProperties": false
                    }
                  },
                  "required": ["logs", "pagination"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/audit-logs/filters": {
      "get": {
        "operationId": "auditLogs-filters",
        "summary": "Get available filter values for audit logs",
        "tags": ["Audit Logs"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "actions": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "resourceTypes": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "actorIds": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": ["actions", "resourceTypes", "actorIds"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/billing/balance": {
      "get": {
        "operationId": "billing-getBalance",
        "summary": "Get account balance and auto top-up config",
        "tags": ["Billing"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "balanceCents": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991
                    },
                    "lowBalanceThresholdCents": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991
                    },
                    "autoTopupEnabled": {
                      "type": "boolean"
                    },
                    "autoTopupAmountCents": {
                      "anyOf": [
                        {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "autoTopupTriggerCents": {
                      "anyOf": [
                        {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "autoTopupMonthlyCapCents": {
                      "anyOf": [
                        {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "autoTopupMonthlySpentCents": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991
                    }
                  },
                  "required": [
                    "balanceCents",
                    "lowBalanceThresholdCents",
                    "autoTopupEnabled",
                    "autoTopupAmountCents",
                    "autoTopupTriggerCents",
                    "autoTopupMonthlyCapCents",
                    "autoTopupMonthlySpentCents"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/billing/check": {
      "post": {
        "operationId": "billing-checkBalance",
        "summary": "Check if org has enough balance for a channel usage",
        "tags": ["Billing"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "channel": {
                    "type": "string",
                    "enum": [
                      "voice_ai",
                      "voice_human",
                      "sms_outbound",
                      "sms_inbound",
                      "chat",
                      "email",
                      "whatsapp",
                      "instagram",
                      "google_reviews",
                      "workflow_run"
                    ]
                  },
                  "quantity": {
                    "default": 1,
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 9007199254740991
                  }
                },
                "required": ["orgId", "channel"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "allowed": {
                      "type": "boolean"
                    },
                    "reason": {
                      "type": "string"
                    },
                    "remainingCents": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991
                    }
                  },
                  "required": ["allowed"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/billing/top-up": {
      "post": {
        "operationId": "billing-topUp",
        "summary": "Add funds to account balance",
        "tags": ["Billing"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "requestId": {
                    "type": "string",
                    "format": "uuid",
                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                  },
                  "amountCents": {
                    "type": "integer",
                    "minimum": 1000,
                    "maximum": 50000
                  }
                },
                "required": ["orgId", "requestId", "amountCents"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "amountCents": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991
                    },
                    "bonusCents": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 9007199254740991
                    },
                    "bonusExpectedCents": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 9007199254740991
                    },
                    "bonusPending": {
                      "type": "boolean"
                    },
                    "status": {
                      "type": "string",
                      "enum": ["pending", "submitted", "review", "settled"]
                    }
                  },
                  "required": [
                    "amountCents",
                    "bonusCents",
                    "bonusExpectedCents",
                    "bonusPending",
                    "status"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/billing/auto-topup": {
      "put": {
        "operationId": "billing-updateAutoTopup",
        "summary": "Configure auto top-up settings",
        "tags": ["Billing"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "enabled": {
                    "type": "boolean"
                  },
                  "thresholdCents": {
                    "type": "integer",
                    "minimum": 100,
                    "maximum": 9007199254740991
                  },
                  "amountCents": {
                    "type": "integer",
                    "minimum": 1000,
                    "maximum": 9007199254740991
                  },
                  "monthlyCap": {
                    "type": "integer",
                    "minimum": 1000,
                    "maximum": 9007199254740991
                  },
                  "consentVersion": {
                    "type": "string",
                    "const": "2026-10-06"
                  }
                },
                "required": ["orgId", "enabled"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    }
                  },
                  "required": ["success"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/billing/plan": {
      "get": {
        "operationId": "billing-getPlan",
        "summary": "Get current billing plan",
        "tags": ["Billing"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "planTier": {
                      "type": "string"
                    },
                    "planCode": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "status": {
                      "type": "string"
                    },
                    "activationState": {
                      "type": "string",
                      "enum": [
                        "unconfigured",
                        "payment_method_required",
                        "ready_to_activate",
                        "payment_pending",
                        "trialing",
                        "active",
                        "admin_trial",
                        "trial_expired",
                        "past_due",
                        "canceled"
                      ]
                    },
                    "selectedPlanTier": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "billingAccountReady": {
                      "type": "boolean"
                    },
                    "hasSubscription": {
                      "type": "boolean"
                    },
                    "trialEnd": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "trialStartedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "firstChargeAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "subscriptionPriceMonthly": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "currentPeriodStart": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "currentPeriodEnd": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "paymentActionUrl": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "cancellationScheduled": {
                      "type": "boolean"
                    },
                    "cancellationPending": {
                      "type": "boolean"
                    },
                    "accessEndsAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "externalCheckoutEnabled": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "planTier",
                    "planCode",
                    "status",
                    "activationState",
                    "selectedPlanTier",
                    "billingAccountReady",
                    "hasSubscription",
                    "trialEnd",
                    "trialStartedAt",
                    "firstChargeAt",
                    "subscriptionPriceMonthly",
                    "currentPeriodStart",
                    "currentPeriodEnd",
                    "paymentActionUrl",
                    "cancellationScheduled",
                    "cancellationPending",
                    "accessEndsAt",
                    "externalCheckoutEnabled"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/billing/choose-plan": {
      "post": {
        "operationId": "billing-choosePlan",
        "summary": "Choose initial billing plan (trial or first subscription)",
        "tags": ["Billing"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "planTier": {
                    "type": "string",
                    "enum": ["starter", "growth"]
                  }
                },
                "required": ["orgId", "planTier"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "activationState": {
                      "type": "string",
                      "const": "payment_method_required"
                    },
                    "stripeCustomerReady": {
                      "type": "boolean"
                    }
                  },
                  "required": ["activationState", "stripeCustomerReady"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/billing/activate-plan": {
      "post": {
        "operationId": "billing-activateSelectedPlan",
        "summary": "Start the selected trial or paid plan after card verification",
        "tags": ["Billing"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "consentVersion": {
                    "type": "string",
                    "const": "2026-10-06"
                  }
                },
                "required": ["orgId", "consentVersion"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "activationState": {
                      "type": "string",
                      "enum": ["payment_pending", "trialing", "active"]
                    },
                    "planTier": {
                      "type": "string",
                      "enum": ["starter", "growth"]
                    },
                    "trialDays": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 9007199254740991
                    },
                    "firstChargeAt": {
                      "type": "string"
                    }
                  },
                  "required": ["activationState", "planTier", "trialDays", "firstChargeAt"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/billing/subscription": {
      "delete": {
        "operationId": "billing-cancelSubscription",
        "summary": "Cancel subscription renewal",
        "tags": ["Billing"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "acknowledgeCancellation",
            "schema": {
              "type": "boolean"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "const": true
                    },
                    "cancellationScheduled": {
                      "type": "boolean"
                    },
                    "cancellationPending": {
                      "type": "boolean"
                    },
                    "accessEndsAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": [
                    "success",
                    "cancellationScheduled",
                    "cancellationPending",
                    "accessEndsAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/billing/change-plan": {
      "put": {
        "operationId": "billing-changePlan",
        "summary": "Change existing subscription plan (upgrade/downgrade)",
        "tags": ["Billing"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "newTier": {
                    "type": "string",
                    "enum": ["starter", "growth"]
                  }
                },
                "required": ["orgId", "newTier"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "const": true
                    },
                    "effectiveTiming": {
                      "type": "string",
                      "enum": ["immediate", "next_billing_period"]
                    },
                    "effectiveAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": ["success", "effectiveTiming", "effectiveAt"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/billing/invoices": {
      "get": {
        "operationId": "billing-getInvoices",
        "summary": "List the organization's invoices",
        "tags": ["Billing"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "page",
            "schema": {
              "default": 1,
              "type": "integer",
              "minimum": 1,
              "maximum": 9007199254740991
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "invoices": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "number": {
                            "type": "string"
                          },
                          "issuingDate": {
                            "type": "string"
                          },
                          "invoiceType": {
                            "type": "string"
                          },
                          "paymentStatus": {
                            "default": "pending",
                            "type": "string",
                            "enum": ["pending", "succeeded", "failed"]
                          },
                          "status": {
                            "default": "finalized",
                            "type": "string",
                            "enum": ["draft", "finalized", "voided"]
                          },
                          "totalAmountCents": {
                            "type": "number"
                          },
                          "currency": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "id",
                          "number",
                          "issuingDate",
                          "invoiceType",
                          "paymentStatus",
                          "status",
                          "totalAmountCents",
                          "currency"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "meta": {
                      "type": "object",
                      "properties": {
                        "currentPage": {
                          "type": "number"
                        },
                        "totalPages": {
                          "type": "number"
                        }
                      },
                      "required": ["currentPage", "totalPages"],
                      "additionalProperties": false
                    }
                  },
                  "required": ["invoices", "meta"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/billing/invoices/download": {
      "post": {
        "operationId": "billing-getInvoiceDownloadUrl",
        "summary": "Get a downloadable PDF URL for an invoice",
        "tags": ["Billing"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "invoiceId": {
                    "type": "string"
                  },
                  "generate": {
                    "default": true,
                    "type": "boolean"
                  }
                },
                "required": ["orgId", "invoiceId"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "url": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": ["url"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/billing/budget": {
      "get": {
        "operationId": "billing-getBudget",
        "summary": "Get budget configuration",
        "tags": ["Billing"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "monthlyBudgetCents": {
                      "anyOf": [
                        {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "alertAt50": {
                      "type": "boolean"
                    },
                    "alertAt75": {
                      "type": "boolean"
                    },
                    "alertAt90": {
                      "type": "boolean"
                    },
                    "alertAt100": {
                      "type": "boolean"
                    },
                    "hardLimit": {
                      "type": "boolean"
                    },
                    "currentPeriodUsageCents": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991
                    },
                    "alertsSentThisPeriod": {
                      "type": "array",
                      "items": {
                        "type": "integer",
                        "minimum": -9007199254740991,
                        "maximum": 9007199254740991
                      }
                    },
                    "webhookUrl": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": [
                    "monthlyBudgetCents",
                    "alertAt50",
                    "alertAt75",
                    "alertAt90",
                    "alertAt100",
                    "hardLimit",
                    "currentPeriodUsageCents",
                    "webhookUrl"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      },
      "put": {
        "operationId": "billing-updateBudget",
        "summary": "Update budget configuration",
        "tags": ["Billing"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "monthlyBudgetCents": {
                    "anyOf": [
                      {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 9007199254740991
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "voiceLimitCents": {
                    "anyOf": [
                      {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 9007199254740991
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "smsLimitCents": {
                    "anyOf": [
                      {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 9007199254740991
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "whatsappLimitCents": {
                    "anyOf": [
                      {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 9007199254740991
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "emailLimitCents": {
                    "anyOf": [
                      {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 9007199254740991
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "alertThreshold": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 100
                  },
                  "alertAt50": {
                    "type": "boolean"
                  },
                  "alertAt75": {
                    "type": "boolean"
                  },
                  "alertAt90": {
                    "type": "boolean"
                  },
                  "alertAt100": {
                    "type": "boolean"
                  },
                  "hardLimit": {
                    "type": "boolean"
                  },
                  "webhookUrl": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "uri"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                },
                "required": ["orgId"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    }
                  },
                  "required": ["success"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/billing/ai-usage": {
      "get": {
        "operationId": "billing-getAIUsageStats",
        "summary": "Get current month AI usage statistics",
        "tags": ["Billing"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "totalCostUSD": {
                      "type": "number"
                    },
                    "totalInputTokens": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991
                    },
                    "totalOutputTokens": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991
                    },
                    "totalTokens": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991
                    },
                    "totalRequests": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991
                    },
                    "cacheHitRate": {
                      "type": "number"
                    },
                    "avgLatencyMs": {
                      "type": "number"
                    },
                    "primaryModel": {
                      "type": "object",
                      "properties": {
                        "name": {
                          "type": "string"
                        },
                        "percentage": {
                          "type": "number"
                        }
                      },
                      "required": ["name", "percentage"],
                      "additionalProperties": false
                    },
                    "topService": {
                      "type": "object",
                      "properties": {
                        "name": {
                          "type": "string"
                        },
                        "percentage": {
                          "type": "number"
                        },
                        "costUSD": {
                          "type": "number"
                        }
                      },
                      "required": ["name", "percentage", "costUSD"],
                      "additionalProperties": false
                    },
                    "byModel": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "model": {
                            "type": "string"
                          },
                          "requests": {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991
                          },
                          "inputTokens": {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991
                          },
                          "outputTokens": {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991
                          },
                          "costUSD": {
                            "type": "number"
                          },
                          "percentage": {
                            "type": "number"
                          }
                        },
                        "required": [
                          "model",
                          "requests",
                          "inputTokens",
                          "outputTokens",
                          "costUSD",
                          "percentage"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "byService": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "service": {
                            "type": "string"
                          },
                          "requests": {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991
                          },
                          "inputTokens": {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991
                          },
                          "outputTokens": {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991
                          },
                          "costUSD": {
                            "type": "number"
                          },
                          "percentage": {
                            "type": "number"
                          }
                        },
                        "required": [
                          "service",
                          "requests",
                          "inputTokens",
                          "outputTokens",
                          "costUSD",
                          "percentage"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "timeSeries": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "timestamp": {
                            "type": "string"
                          },
                          "requests": {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991
                          },
                          "tokens": {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991
                          },
                          "costUSD": {
                            "type": "number"
                          }
                        },
                        "required": ["timestamp", "requests", "tokens", "costUSD"],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": [
                    "totalCostUSD",
                    "totalInputTokens",
                    "totalOutputTokens",
                    "totalTokens",
                    "totalRequests",
                    "cacheHitRate",
                    "avgLatencyMs",
                    "primaryModel",
                    "topService",
                    "byModel",
                    "byService",
                    "timeSeries"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/billing/setup-intent": {
      "post": {
        "operationId": "billing-createSetupIntent",
        "summary": "Create a Stripe SetupIntent to add a payment method",
        "tags": ["Billing"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  }
                },
                "required": ["orgId"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "clientSecret": {
                      "type": "string"
                    },
                    "publishableKey": {
                      "type": "string"
                    }
                  },
                  "required": ["clientSecret", "publishableKey"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/billing/payment-methods": {
      "get": {
        "operationId": "billing-listPaymentMethods",
        "summary": "List saved payment methods",
        "tags": ["Billing"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "cards": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "brand": {
                            "type": "string"
                          },
                          "last4": {
                            "type": "string"
                          },
                          "expMonth": {
                            "type": "number"
                          },
                          "expYear": {
                            "type": "number"
                          },
                          "isDefault": {
                            "type": "boolean"
                          }
                        },
                        "required": ["id", "brand", "last4", "expMonth", "expYear", "isDefault"],
                        "additionalProperties": false
                      }
                    },
                    "publishableKey": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": ["cards", "publishableKey"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "billing-removePaymentMethod",
        "summary": "Remove a saved payment method",
        "tags": ["Billing"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "paymentMethodId",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    }
                  },
                  "required": ["success"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/billing/payment-methods/synchronize": {
      "post": {
        "operationId": "billing-synchronizePaymentMethod",
        "summary": "Synchronize a saved Stripe card with billing",
        "tags": ["Billing"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "paymentMethodId": {
                    "type": "string"
                  },
                  "makeDefault": {
                    "type": "boolean"
                  }
                },
                "required": ["orgId", "paymentMethodId", "makeDefault"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "activationState": {
                      "type": "string",
                      "enum": [
                        "unconfigured",
                        "payment_method_required",
                        "ready_to_activate",
                        "payment_pending",
                        "trialing",
                        "active",
                        "admin_trial",
                        "trial_expired",
                        "past_due",
                        "canceled"
                      ]
                    },
                    "paymentRetry": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "retried": {
                              "type": "number"
                            },
                            "skipped": {
                              "type": "number"
                            }
                          },
                          "required": ["retried", "skipped"],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": ["success", "activationState", "paymentRetry"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/billing/payment-methods/default": {
      "post": {
        "operationId": "billing-setDefaultPaymentMethod",
        "summary": "Set the default payment method",
        "tags": ["Billing"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "paymentMethodId": {
                    "type": "string"
                  }
                },
                "required": ["orgId", "paymentMethodId"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "paymentRetry": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "retried": {
                              "type": "number"
                            },
                            "skipped": {
                              "type": "number"
                            }
                          },
                          "required": ["retried", "skipped"],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": ["success", "paymentRetry"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/billing/retry-payment": {
      "post": {
        "operationId": "billing-retryFailedPayment",
        "summary": "Retry failed subscription payments",
        "tags": ["Billing"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  }
                },
                "required": ["orgId"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "retried": {
                      "type": "number"
                    },
                    "skipped": {
                      "type": "number"
                    }
                  },
                  "required": ["retried", "skipped"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/billing/details": {
      "get": {
        "operationId": "billing-getBillingDetails",
        "summary": "Get invoice billing details",
        "tags": ["Billing"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "legalName": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 200
                    },
                    "email": {
                      "type": "string",
                      "maxLength": 254,
                      "format": "email",
                      "pattern": "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
                    },
                    "addressLine1": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 200
                    },
                    "addressLine2": {
                      "type": "string",
                      "maxLength": 200
                    },
                    "city": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 100
                    },
                    "state": {
                      "type": "string",
                      "maxLength": 100
                    },
                    "zipcode": {
                      "type": "string",
                      "maxLength": 20
                    },
                    "country": {
                      "type": "string"
                    },
                    "taxId": {
                      "type": "string",
                      "maxLength": 50
                    },
                    "name": {
                      "type": "string"
                    }
                  },
                  "required": ["name"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "billing-updateBillingDetails",
        "summary": "Update invoice billing details",
        "tags": ["Billing"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "details": {
                    "type": "object",
                    "properties": {
                      "legalName": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 200
                      },
                      "email": {
                        "type": "string",
                        "maxLength": 254,
                        "format": "email",
                        "pattern": "^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
                      },
                      "addressLine1": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 200
                      },
                      "addressLine2": {
                        "type": "string",
                        "maxLength": 200
                      },
                      "city": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 100
                      },
                      "state": {
                        "type": "string",
                        "maxLength": 100
                      },
                      "zipcode": {
                        "type": "string",
                        "maxLength": 20
                      },
                      "country": {
                        "type": "string",
                        "pattern": "^[A-Za-z]{2}$"
                      },
                      "taxId": {
                        "type": "string",
                        "maxLength": 50
                      }
                    },
                    "required": ["legalName", "email", "addressLine1", "city", "country"]
                  }
                },
                "required": ["orgId", "details"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    }
                  },
                  "required": ["success"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/feedback/scores/{conversationId}": {
      "get": {
        "operationId": "feedback-getConversationScore",
        "summary": "Get AI-predicted satisfaction score for a conversation",
        "tags": ["Feedback"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "conversationId",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "conversationId": {
                          "type": "string"
                        },
                        "predictedCSAT": {
                          "anyOf": [
                            {
                              "type": "number"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "customerEffortScore": {
                          "anyOf": [
                            {
                              "type": "number"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "resolutionQuality": {
                          "anyOf": [
                            {
                              "type": "number"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "sentiment": {
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": ["positive", "negative", "neutral", "mixed"]
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "sentimentScore": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "topics": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "primaryCategory": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "emergingThemes": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "churnRisk": {
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": ["low", "medium", "high"]
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "escalationNeeded": {
                          "type": "boolean"
                        },
                        "resolutionType": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "customerConfirmedResolution": {
                          "anyOf": [
                            {
                              "type": "boolean"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "modelVersion": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "confidence": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "processedAt": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "id",
                        "conversationId",
                        "predictedCSAT",
                        "customerEffortScore",
                        "resolutionQuality",
                        "sentiment",
                        "sentimentScore",
                        "topics",
                        "primaryCategory",
                        "emergingThemes",
                        "churnRisk",
                        "escalationNeeded",
                        "resolutionType",
                        "customerConfirmedResolution",
                        "modelVersion",
                        "confidence",
                        "processedAt"
                      ],
                      "additionalProperties": false
                    },
                    {
                      "type": "null"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/feedback/surveys/{surveyId}/step": {
      "post": {
        "operationId": "feedback-submitSurveyStep",
        "summary": "Submit a survey step response",
        "tags": ["Feedback"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "surveyId",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "issueResolved": {
                    "type": "boolean"
                  },
                  "cesRating": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 7
                  },
                  "openEndedResponse": {
                    "type": "string",
                    "maxLength": 2000
                  },
                  "aiFollowUpResponse": {
                    "type": "string",
                    "maxLength": 2000
                  }
                },
                "required": ["orgId"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "conversationId": {
                      "type": "string"
                    },
                    "contactId": {
                      "type": "string"
                    },
                    "channel": {
                      "type": "string"
                    },
                    "currentStep": {
                      "type": "string"
                    },
                    "issueResolved": {
                      "anyOf": [
                        {
                          "type": "boolean"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "cesRating": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "openEndedResponse": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "aiFollowUpQuestion": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "aiFollowUpResponse": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "sentAt": {
                      "type": "string"
                    },
                    "completedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": [
                    "id",
                    "conversationId",
                    "contactId",
                    "channel",
                    "currentStep",
                    "issueResolved",
                    "cesRating",
                    "openEndedResponse",
                    "aiFollowUpQuestion",
                    "aiFollowUpResponse",
                    "sentAt",
                    "completedAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/feedback/surveys/by-conversation/{conversationId}": {
      "get": {
        "operationId": "feedback-getSurveyByConversation",
        "summary": "Get survey for a conversation",
        "tags": ["Feedback"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "conversationId",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "conversationId": {
                          "type": "string"
                        },
                        "contactId": {
                          "type": "string"
                        },
                        "channel": {
                          "type": "string"
                        },
                        "currentStep": {
                          "type": "string"
                        },
                        "issueResolved": {
                          "anyOf": [
                            {
                              "type": "boolean"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "cesRating": {
                          "anyOf": [
                            {
                              "type": "number"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "openEndedResponse": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "aiFollowUpQuestion": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "aiFollowUpResponse": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "sentAt": {
                          "type": "string"
                        },
                        "completedAt": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      },
                      "required": [
                        "id",
                        "conversationId",
                        "contactId",
                        "channel",
                        "currentStep",
                        "issueResolved",
                        "cesRating",
                        "openEndedResponse",
                        "aiFollowUpQuestion",
                        "aiFollowUpResponse",
                        "sentAt",
                        "completedAt"
                      ],
                      "additionalProperties": false
                    },
                    {
                      "type": "null"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/feedback/summary": {
      "get": {
        "operationId": "feedback-summary",
        "summary": "Get org-level feedback summary",
        "tags": ["Feedback"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "fromDate",
            "schema": {
              "type": "string",
              "format": "date-time",
              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "toDate",
            "schema": {
              "type": "string",
              "format": "date-time",
              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "avgPredictedCSAT": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "avgCES": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "totalScored": {
                      "type": "number"
                    },
                    "totalSurveyed": {
                      "type": "number"
                    },
                    "totalResponded": {
                      "type": "number"
                    },
                    "sentimentBreakdown": {
                      "type": "object",
                      "propertyNames": {
                        "type": "string"
                      },
                      "additionalProperties": {
                        "type": "number"
                      }
                    },
                    "topTopics": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "topic": {
                            "type": "string"
                          },
                          "count": {
                            "type": "number"
                          }
                        },
                        "required": ["topic", "count"],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": [
                    "avgPredictedCSAT",
                    "avgCES",
                    "totalScored",
                    "totalSurveyed",
                    "totalResponded",
                    "sentimentBreakdown",
                    "topTopics"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/feedback/ttr": {
      "get": {
        "operationId": "feedback-ttrMetrics",
        "summary": "Get Time-to-Resolution metrics",
        "tags": ["Feedback"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "fromDate",
            "schema": {
              "type": "string",
              "format": "date-time",
              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "toDate",
            "schema": {
              "type": "string",
              "format": "date-time",
              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "avgFullResolutionMs": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "avgFirstResolutionMs": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "resolutionBreakdown": {
                      "type": "object",
                      "propertyNames": {
                        "type": "string"
                      },
                      "additionalProperties": {
                        "type": "number"
                      }
                    },
                    "reopenRate": {
                      "type": "number"
                    },
                    "abandonedRate": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "avgFullResolutionMs",
                    "avgFirstResolutionMs",
                    "resolutionBreakdown",
                    "reopenRate",
                    "abandonedRate"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/feedback/learning-velocity": {
      "get": {
        "operationId": "feedback-learningVelocity",
        "summary": "Get AI learning velocity metrics",
        "tags": ["Feedback"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "fromDate",
            "schema": {
              "type": "string",
              "format": "date-time",
              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "toDate",
            "schema": {
              "type": "string",
              "format": "date-time",
              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "extracted": {
                      "type": "number"
                    },
                    "approved": {
                      "type": "number"
                    },
                    "autoApproved": {
                      "type": "number"
                    },
                    "applied": {
                      "type": "number"
                    },
                    "avgConfidence": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": ["extracted", "approved", "autoApproved", "applied", "avgConfidence"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/feedback/taxonomy": {
      "get": {
        "operationId": "feedback-taxonomy",
        "summary": "Get the controlled feedback taxonomy",
        "tags": ["Feedback"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "categories": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": ["categories"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/auto-resolve-config": {
      "get": {
        "operationId": "autoResolveConfig-get",
        "summary": "Get auto-resolve and business hours configuration",
        "tags": ["Auto-Resolve Config"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "orgId": {
                      "type": "string"
                    },
                    "timezone": {
                      "type": "string"
                    },
                    "schedule": {},
                    "holidays": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "is24x7": {
                      "type": "boolean"
                    },
                    "autoResolveConfig": {}
                  },
                  "required": [
                    "id",
                    "orgId",
                    "timezone",
                    "schedule",
                    "holidays",
                    "is24x7",
                    "autoResolveConfig"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/auto-resolve-config/auto-resolve": {
      "put": {
        "operationId": "autoResolveConfig-updateAutoResolve",
        "summary": "Update auto-resolve configuration",
        "tags": ["Auto-Resolve Config"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "enabled": {
                    "type": "boolean"
                  },
                  "channels": {
                    "type": "object",
                    "propertyNames": {
                      "type": "string"
                    },
                    "additionalProperties": {
                      "type": "object",
                      "properties": {
                        "followUpDelaySec": {
                          "type": "integer",
                          "minimum": 30,
                          "maximum": 604800
                        },
                        "warningDelaySec": {
                          "type": "integer",
                          "minimum": 30,
                          "maximum": 604800
                        },
                        "graceDelaySec": {
                          "type": "integer",
                          "minimum": 30,
                          "maximum": 604800
                        },
                        "enableSurvey": {
                          "type": "boolean"
                        }
                      },
                      "required": [
                        "followUpDelaySec",
                        "warningDelaySec",
                        "graceDelaySec",
                        "enableSurvey"
                      ]
                    }
                  },
                  "followUpMessage": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "warningMessage": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "closedMessage": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "cooldownBeforeNewConversationSec": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 9007199254740991
                  },
                  "maxReopenCount": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 50
                  },
                  "aiConfidenceThreshold": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 1
                  },
                  "preventOnOpenEscalation": {
                    "type": "boolean"
                  },
                  "preventOnNegativeSentiment": {
                    "type": "boolean"
                  },
                  "preventOnPendingStatus": {
                    "type": "boolean"
                  },
                  "survey": {
                    "type": "object",
                    "properties": {
                      "enabled": {
                        "type": "boolean"
                      },
                      "sampleRate": {
                        "type": "number",
                        "minimum": 0,
                        "maximum": 1
                      },
                      "maxPerContactPerMonth": {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 10
                      },
                      "minDaysBetweenSurveys": {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 365
                      },
                      "primaryMetric": {
                        "type": "string",
                        "enum": ["ces", "csat"]
                      },
                      "enableAIFollowUp": {
                        "type": "boolean"
                      },
                      "enableResolutionGate": {
                        "type": "boolean"
                      }
                    },
                    "required": [
                      "enabled",
                      "sampleRate",
                      "maxPerContactPerMonth",
                      "minDaysBetweenSurveys",
                      "primaryMetric",
                      "enableAIFollowUp",
                      "enableResolutionGate"
                    ]
                  },
                  "aiScoring": {
                    "type": "object",
                    "properties": {
                      "enabled": {
                        "type": "boolean"
                      },
                      "scoreEveryConversation": {
                        "type": "boolean"
                      }
                    },
                    "required": ["enabled", "scoreEveryConversation"]
                  }
                },
                "required": ["orgId", "enabled"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "orgId": {
                      "type": "string"
                    },
                    "timezone": {
                      "type": "string"
                    },
                    "schedule": {},
                    "holidays": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "is24x7": {
                      "type": "boolean"
                    },
                    "autoResolveConfig": {}
                  },
                  "required": [
                    "id",
                    "orgId",
                    "timezone",
                    "schedule",
                    "holidays",
                    "is24x7",
                    "autoResolveConfig"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/auto-resolve-config/business-hours": {
      "put": {
        "operationId": "autoResolveConfig-updateBusinessHours",
        "summary": "Update business hours configuration",
        "tags": ["Auto-Resolve Config"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "timezone": {
                    "type": "string"
                  },
                  "schedule": {
                    "type": "object",
                    "propertyNames": {
                      "type": "string"
                    },
                    "additionalProperties": {
                      "type": "object",
                      "properties": {
                        "start": {
                          "type": "string"
                        },
                        "end": {
                          "type": "string"
                        }
                      },
                      "required": ["start", "end"]
                    }
                  },
                  "holidays": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "is24x7": {
                    "type": "boolean"
                  }
                },
                "required": ["orgId"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "orgId": {
                      "type": "string"
                    },
                    "timezone": {
                      "type": "string"
                    },
                    "schedule": {},
                    "holidays": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "is24x7": {
                      "type": "boolean"
                    },
                    "autoResolveConfig": {}
                  },
                  "required": [
                    "id",
                    "orgId",
                    "timezone",
                    "schedule",
                    "holidays",
                    "is24x7",
                    "autoResolveConfig"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/automations/http-connections": {
      "get": {
        "operationId": "automations-httpConnections-list",
        "summary": "List signed workflow destinations without credentials",
        "tags": ["Automations"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "connections": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "url": {
                            "type": "string"
                          },
                          "status": {
                            "type": "string",
                            "enum": ["active", "paused"]
                          },
                          "secretConfigured": {
                            "type": "boolean"
                          },
                          "createdAt": {
                            "type": "string"
                          },
                          "updatedAt": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "id",
                          "name",
                          "url",
                          "status",
                          "secretConfigured",
                          "createdAt",
                          "updatedAt"
                        ],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": ["connections"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "automations-httpConnections-create",
        "summary": "Configure a signed workflow destination",
        "tags": ["Automations"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 120
                  },
                  "url": {
                    "type": "string",
                    "maxLength": 2048
                  },
                  "secret": {
                    "type": "string",
                    "minLength": 32,
                    "maxLength": 2000
                  },
                  "idempotencyKey": {
                    "type": "string",
                    "pattern": "^[A-Za-z0-9_-]{8,128}$"
                  }
                },
                "required": ["orgId", "name", "url", "secret", "idempotencyKey"],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "url": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string",
                      "enum": ["active", "paused"]
                    },
                    "secretConfigured": {
                      "type": "boolean"
                    },
                    "createdAt": {
                      "type": "string"
                    },
                    "updatedAt": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "id",
                    "name",
                    "url",
                    "status",
                    "secretConfigured",
                    "createdAt",
                    "updatedAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/automations/http-connections/{id}/status": {
      "post": {
        "operationId": "automations-httpConnections-setStatus",
        "summary": "Pause or resume a signed workflow destination",
        "tags": ["Automations"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "status": {
                    "type": "string",
                    "enum": ["active", "paused"]
                  }
                },
                "required": ["orgId", "status"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "url": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string",
                      "enum": ["active", "paused"]
                    },
                    "secretConfigured": {
                      "type": "boolean"
                    },
                    "createdAt": {
                      "type": "string"
                    },
                    "updatedAt": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "id",
                    "name",
                    "url",
                    "status",
                    "secretConfigured",
                    "createdAt",
                    "updatedAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/devices/register": {
      "post": {
        "operationId": "devices-register",
        "summary": "Register a push notification device token",
        "tags": ["Devices"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "token": {
                    "type": "string",
                    "minLength": 1
                  },
                  "platform": {
                    "type": "string",
                    "enum": ["ios", "android"]
                  },
                  "deviceName": {
                    "type": "string",
                    "maxLength": 120
                  }
                },
                "required": ["token", "platform"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "userId": {
                      "type": "string"
                    },
                    "token": {
                      "type": "string"
                    },
                    "platform": {
                      "type": "string"
                    },
                    "deviceName": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "lastSeenAt": {
                      "type": "string"
                    },
                    "disabledAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "createdAt": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "id",
                    "userId",
                    "token",
                    "platform",
                    "deviceName",
                    "lastSeenAt",
                    "disabledAt",
                    "createdAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/devices/remove": {
      "post": {
        "operationId": "devices-remove",
        "summary": "Remove a push notification device token",
        "tags": ["Devices"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "token": {
                    "type": "string",
                    "minLength": 1
                  }
                },
                "required": ["token"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "removed": {
                      "type": "number"
                    }
                  },
                  "required": ["removed"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/notification-preferences": {
      "get": {
        "operationId": "notificationPrefs-get",
        "summary": "Get the current user's notification preferences",
        "tags": ["Notifications"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "topics": {
                      "type": "object",
                      "properties": {
                        "escalations": {
                          "type": "boolean"
                        },
                        "conversations": {
                          "type": "boolean"
                        },
                        "billing": {
                          "type": "boolean"
                        },
                        "agents": {
                          "type": "boolean"
                        },
                        "briefing": {
                          "type": "boolean"
                        }
                      },
                      "required": ["escalations", "conversations", "billing", "agents", "briefing"],
                      "additionalProperties": false
                    },
                    "showPreviews": {
                      "type": "boolean"
                    },
                    "quietHoursEnabled": {
                      "type": "boolean"
                    },
                    "quietStart": {
                      "type": "string",
                      "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                    },
                    "quietEnd": {
                      "type": "string",
                      "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                    },
                    "timezone": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "topics",
                    "showPreviews",
                    "quietHoursEnabled",
                    "quietStart",
                    "quietEnd",
                    "timezone"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "notificationPrefs-update",
        "summary": "Update the current user's notification preferences",
        "tags": ["Notifications"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "topics": {
                    "type": "object",
                    "properties": {
                      "escalations": {
                        "type": "boolean"
                      },
                      "conversations": {
                        "type": "boolean"
                      },
                      "billing": {
                        "type": "boolean"
                      },
                      "agents": {
                        "type": "boolean"
                      },
                      "briefing": {
                        "type": "boolean"
                      }
                    }
                  },
                  "showPreviews": {
                    "type": "boolean"
                  },
                  "quietHoursEnabled": {
                    "type": "boolean"
                  },
                  "quietStart": {
                    "type": "string",
                    "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                  },
                  "quietEnd": {
                    "type": "string",
                    "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                  },
                  "timezone": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "topics": {
                      "type": "object",
                      "properties": {
                        "escalations": {
                          "type": "boolean"
                        },
                        "conversations": {
                          "type": "boolean"
                        },
                        "billing": {
                          "type": "boolean"
                        },
                        "agents": {
                          "type": "boolean"
                        },
                        "briefing": {
                          "type": "boolean"
                        }
                      },
                      "required": ["escalations", "conversations", "billing", "agents", "briefing"],
                      "additionalProperties": false
                    },
                    "showPreviews": {
                      "type": "boolean"
                    },
                    "quietHoursEnabled": {
                      "type": "boolean"
                    },
                    "quietStart": {
                      "type": "string",
                      "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                    },
                    "quietEnd": {
                      "type": "string",
                      "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                    },
                    "timezone": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "topics",
                    "showPreviews",
                    "quietHoursEnabled",
                    "quietStart",
                    "quietEnd",
                    "timezone"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/analytics/summary": {
      "get": {
        "operationId": "analytics-summary",
        "summary": "Conversation volume trend and status/channel/assignee mix for a period",
        "tags": ["Analytics"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "required": true
          },
          {
            "in": "query",
            "name": "period",
            "schema": {
              "default": "week",
              "type": "string",
              "enum": ["day", "week", "month"]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "start": {
                      "type": "string"
                    },
                    "bucketMs": {
                      "type": "number"
                    },
                    "buckets": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "total": {
                            "type": "number"
                          },
                          "ai": {
                            "type": "number"
                          },
                          "resolved": {
                            "type": "number"
                          }
                        },
                        "required": ["total", "ai", "resolved"],
                        "additionalProperties": false
                      }
                    },
                    "total": {
                      "type": "number"
                    },
                    "ai": {
                      "type": "number"
                    },
                    "resolved": {
                      "type": "number"
                    },
                    "prevTotal": {
                      "type": "number"
                    },
                    "statusCounts": {
                      "type": "object",
                      "propertyNames": {
                        "type": "string"
                      },
                      "additionalProperties": {
                        "type": "number"
                      }
                    },
                    "channelCounts": {
                      "type": "object",
                      "propertyNames": {
                        "type": "string"
                      },
                      "additionalProperties": {
                        "type": "number"
                      }
                    },
                    "assigneeCounts": {
                      "type": "object",
                      "propertyNames": {
                        "type": "string"
                      },
                      "additionalProperties": {
                        "type": "number"
                      }
                    }
                  },
                  "required": [
                    "start",
                    "bucketMs",
                    "buckets",
                    "total",
                    "ai",
                    "resolved",
                    "prevTotal",
                    "statusCounts",
                    "channelCounts",
                    "assigneeCounts"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/analytics/trends": {
      "get": {
        "operationId": "analytics-trends",
        "summary": "Conversation + AI-resolution time-series for the Insights charts",
        "tags": ["Analytics"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "required": true
          },
          {
            "in": "query",
            "name": "range",
            "schema": {
              "default": "7d",
              "type": "string",
              "enum": ["today", "7d", "30d"]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "granularity": {
                      "type": "string",
                      "enum": ["hour", "day"]
                    },
                    "conversations": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "bucket": {
                            "type": "string"
                          },
                          "value": {
                            "type": "number"
                          }
                        },
                        "required": ["bucket", "value"],
                        "additionalProperties": false
                      }
                    },
                    "aiResolutionShare": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "bucket": {
                            "type": "string"
                          },
                          "value": {
                            "type": "number"
                          }
                        },
                        "required": ["bucket", "value"],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": ["granularity", "conversations", "aiResolutionShare"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/outbound/status": {
      "get": {
        "operationId": "outbound-status",
        "summary": "Get outbound calling readiness, limits and current usage",
        "tags": ["Outbound"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "enablement": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "enabled": {
                              "type": "boolean",
                              "const": true
                            }
                          },
                          "required": ["enabled"],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "enabled": {
                              "type": "boolean",
                              "const": false
                            },
                            "reason": {
                              "type": "string",
                              "enum": ["capability_off", "org_disabled"]
                            },
                            "detail": {
                              "type": "string"
                            }
                          },
                          "required": ["enabled", "reason", "detail"],
                          "additionalProperties": false
                        }
                      ]
                    },
                    "limits": {
                      "type": "object",
                      "properties": {
                        "concurrentCalls": {
                          "type": "integer",
                          "exclusiveMinimum": 0,
                          "maximum": 9007199254740991
                        },
                        "callsPerDay": {
                          "type": "integer",
                          "exclusiveMinimum": 0,
                          "maximum": 9007199254740991
                        },
                        "requestsPerCampaign": {
                          "type": "integer",
                          "exclusiveMinimum": 0,
                          "maximum": 9007199254740991
                        },
                        "testNumbers": {
                          "type": "integer",
                          "exclusiveMinimum": 0,
                          "maximum": 9007199254740991
                        }
                      },
                      "required": [
                        "concurrentCalls",
                        "callsPerDay",
                        "requestsPerCampaign",
                        "testNumbers"
                      ],
                      "additionalProperties": false
                    },
                    "usage": {
                      "type": "object",
                      "properties": {
                        "liveCalls": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 9007199254740991
                        },
                        "callsToday": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 9007199254740991
                        }
                      },
                      "required": ["liveCalls", "callsToday"],
                      "additionalProperties": false
                    },
                    "capability": {
                      "type": "string",
                      "enum": ["launch", "beta", "off"]
                    }
                  },
                  "required": ["enablement", "limits", "usage", "capability"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/outbound/check": {
      "post": {
        "operationId": "outbound-check",
        "summary": "Preview outbound policy eligibility without creating a call",
        "description": "Inline consent is evaluated in memory and never stored. Treats the campaign as running to preview draft and paused campaigns; enablement and all other policies still apply.",
        "tags": ["Outbound"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "campaignId": {
                    "type": "string"
                  },
                  "phone": {
                    "type": "string"
                  },
                  "consent": {
                    "type": "object",
                    "properties": {
                      "sourceId": {
                        "type": "string"
                      },
                      "capturedAt": {
                        "type": "string"
                      },
                      "ipAddress": {
                        "type": "string"
                      },
                      "pageUrl": {
                        "type": "string"
                      },
                      "sourceRef": {
                        "type": "string"
                      }
                    },
                    "required": ["sourceId", "capturedAt"]
                  }
                },
                "required": ["orgId", "campaignId", "phone"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "allowed": {
                      "type": "boolean"
                    },
                    "denyReason": {
                      "type": "string",
                      "enum": [
                        "capability_off",
                        "org_disabled",
                        "country_disabled",
                        "number_not_allowed",
                        "caller_id_mismatch",
                        "timezone_unknown",
                        "outside_window",
                        "holiday",
                        "no_consent",
                        "consent_insufficient",
                        "consent_expired",
                        "consent_source_unapproved",
                        "suppressed",
                        "opted_out_channel",
                        "attempt_limit",
                        "retry_gap",
                        "daily_cap",
                        "campaign_hourly_cap",
                        "concurrency_cap",
                        "insufficient_balance",
                        "campaign_not_running",
                        "already_active"
                      ]
                    },
                    "terminal": {
                      "type": "boolean"
                    },
                    "nextEligibleAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "variantKey": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": ["A", "B", "C"]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": ["allowed", "variantKey"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/outbound/preview": {
      "post": {
        "operationId": "outbound-preview",
        "summary": "Preview up to 1000 leads in one read-only policy batch",
        "description": "Treats draft or paused campaigns as running. Does not reserve capacity, create consent or queue calls. Every destination is checked again before dialing.",
        "tags": ["Outbound"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "campaignId": {
                    "type": "string"
                  },
                  "phones": {
                    "minItems": 1,
                    "maxItems": 1000,
                    "type": "array",
                    "items": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 32
                    }
                  }
                },
                "required": ["orgId", "campaignId", "phones"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "results": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "index": {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991
                          },
                          "allowed": {
                            "type": "boolean"
                          },
                          "variantKey": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": ["A", "B", "C"]
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "denyReason": {
                            "type": "string",
                            "enum": [
                              "capability_off",
                              "org_disabled",
                              "country_disabled",
                              "number_not_allowed",
                              "caller_id_mismatch",
                              "timezone_unknown",
                              "outside_window",
                              "holiday",
                              "no_consent",
                              "consent_insufficient",
                              "consent_expired",
                              "consent_source_unapproved",
                              "suppressed",
                              "opted_out_channel",
                              "attempt_limit",
                              "retry_gap",
                              "daily_cap",
                              "campaign_hourly_cap",
                              "concurrency_cap",
                              "insufficient_balance",
                              "campaign_not_running",
                              "already_active"
                            ]
                          },
                          "terminal": {
                            "type": "boolean"
                          },
                          "nextEligibleAt": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        },
                        "required": ["index", "allowed", "variantKey"],
                        "additionalProperties": false
                      }
                    },
                    "summary": {
                      "type": "object",
                      "properties": {
                        "total": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "allowed": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "reasons": {
                          "type": "object",
                          "propertyNames": {
                            "type": "string",
                            "enum": [
                              "capability_off",
                              "org_disabled",
                              "country_disabled",
                              "number_not_allowed",
                              "caller_id_mismatch",
                              "timezone_unknown",
                              "outside_window",
                              "holiday",
                              "no_consent",
                              "consent_insufficient",
                              "consent_expired",
                              "consent_source_unapproved",
                              "suppressed",
                              "opted_out_channel",
                              "attempt_limit",
                              "retry_gap",
                              "daily_cap",
                              "campaign_hourly_cap",
                              "concurrency_cap",
                              "insufficient_balance",
                              "campaign_not_running",
                              "already_active"
                            ]
                          },
                          "additionalProperties": {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991
                          }
                        }
                      },
                      "required": ["total", "allowed", "reasons"],
                      "additionalProperties": false
                    }
                  },
                  "required": ["results", "summary"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/outbound/campaigns/{id}/stats": {
      "get": {
        "operationId": "outbound-campaigns-stats",
        "summary": "Campaign experiment results and confidence intervals",
        "tags": ["Outbound"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "variants": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "key": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "dialed": {
                            "type": "number"
                          },
                          "human": {
                            "type": "number"
                          },
                          "voicemail": {
                            "type": "number"
                          },
                          "transfers": {
                            "type": "number"
                          },
                          "optOuts": {
                            "type": "number"
                          },
                          "succeeded": {
                            "type": "number"
                          },
                          "shortHangUps": {
                            "type": "number"
                          },
                          "talkTimeSeconds": {
                            "type": "number"
                          },
                          "cost": {
                            "type": "number"
                          },
                          "successRate": {
                            "type": "number"
                          },
                          "confidenceInterval": {
                            "type": "array",
                            "prefixItems": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "number"
                              }
                            ]
                          }
                        },
                        "required": [
                          "id",
                          "key",
                          "name",
                          "dialed",
                          "human",
                          "voicemail",
                          "transfers",
                          "optOuts",
                          "succeeded",
                          "shortHangUps",
                          "talkTimeSeconds",
                          "cost",
                          "successRate",
                          "confidenceInterval"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "winnerId": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": ["variants", "winnerId"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/outbound/campaigns": {
      "post": {
        "operationId": "outbound-campaigns-create",
        "summary": "Create an outbound campaign draft",
        "tags": ["Outbound"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 120
                  },
                  "purpose": {
                    "type": "string",
                    "enum": ["marketing", "lead_followup", "service"]
                  },
                  "alwaysOn": {
                    "type": "boolean"
                  },
                  "inboxId": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 128
                  },
                  "settings": {
                    "type": "object",
                    "properties": {
                      "brief": {
                        "default": "",
                        "type": "string",
                        "maxLength": 4000
                      },
                      "purposeLine": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 200
                      },
                      "addressOrFreephone": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 200
                      },
                      "schedule": {
                        "default": {},
                        "type": "object",
                        "properties": {
                          "startAt": {
                            "type": "string",
                            "format": "date-time",
                            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                          },
                          "endAt": {
                            "type": "string",
                            "format": "date-time",
                            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                          },
                          "windows": {
                            "type": "object",
                            "properties": {
                              "sun": {
                                "maxItems": 4,
                                "type": "array",
                                "items": {
                                  "type": "array",
                                  "prefixItems": [
                                    {
                                      "type": "string",
                                      "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                    },
                                    {
                                      "type": "string",
                                      "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                    }
                                  ]
                                }
                              },
                              "mon": {
                                "maxItems": 4,
                                "type": "array",
                                "items": {
                                  "type": "array",
                                  "prefixItems": [
                                    {
                                      "type": "string",
                                      "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                    },
                                    {
                                      "type": "string",
                                      "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                    }
                                  ]
                                }
                              },
                              "tue": {
                                "maxItems": 4,
                                "type": "array",
                                "items": {
                                  "type": "array",
                                  "prefixItems": [
                                    {
                                      "type": "string",
                                      "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                    },
                                    {
                                      "type": "string",
                                      "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                    }
                                  ]
                                }
                              },
                              "wed": {
                                "maxItems": 4,
                                "type": "array",
                                "items": {
                                  "type": "array",
                                  "prefixItems": [
                                    {
                                      "type": "string",
                                      "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                    },
                                    {
                                      "type": "string",
                                      "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                    }
                                  ]
                                }
                              },
                              "thu": {
                                "maxItems": 4,
                                "type": "array",
                                "items": {
                                  "type": "array",
                                  "prefixItems": [
                                    {
                                      "type": "string",
                                      "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                    },
                                    {
                                      "type": "string",
                                      "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                    }
                                  ]
                                }
                              },
                              "fri": {
                                "maxItems": 4,
                                "type": "array",
                                "items": {
                                  "type": "array",
                                  "prefixItems": [
                                    {
                                      "type": "string",
                                      "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                    },
                                    {
                                      "type": "string",
                                      "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                    }
                                  ]
                                }
                              },
                              "sat": {
                                "maxItems": 4,
                                "type": "array",
                                "items": {
                                  "type": "array",
                                  "prefixItems": [
                                    {
                                      "type": "string",
                                      "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                    },
                                    {
                                      "type": "string",
                                      "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                    }
                                  ]
                                }
                              }
                            },
                            "additionalProperties": false
                          }
                        },
                        "additionalProperties": false
                      },
                      "pacing": {
                        "default": {
                          "maxConcurrent": 2,
                          "maxPerHour": 60,
                          "maxNewNumbersPerHour": 30
                        },
                        "type": "object",
                        "properties": {
                          "maxConcurrent": {
                            "default": 2,
                            "type": "integer",
                            "minimum": 1,
                            "maximum": 50
                          },
                          "maxPerHour": {
                            "default": 60,
                            "type": "integer",
                            "minimum": 1,
                            "maximum": 5000
                          },
                          "maxNewNumbersPerHour": {
                            "default": 30,
                            "type": "integer",
                            "minimum": 1,
                            "maximum": 1000
                          }
                        },
                        "additionalProperties": false
                      },
                      "retry": {
                        "default": {
                          "maxAttempts": 3,
                          "retryOn": ["no_answer", "busy", "voicemail"],
                          "gapMinutes": 240
                        },
                        "type": "object",
                        "properties": {
                          "maxAttempts": {
                            "default": 3,
                            "type": "integer",
                            "minimum": 1,
                            "maximum": 3
                          },
                          "retryOn": {
                            "default": ["no_answer", "busy", "voicemail"],
                            "maxItems": 10,
                            "type": "array",
                            "items": {
                              "type": "string",
                              "enum": [
                                "human",
                                "voicemail",
                                "fax",
                                "no_answer",
                                "busy",
                                "failed",
                                "canceled",
                                "transferred",
                                "opted_out",
                                "abandoned"
                              ]
                            }
                          },
                          "gapMinutes": {
                            "default": 240,
                            "type": "integer",
                            "minimum": 240,
                            "maximum": 10080
                          }
                        },
                        "additionalProperties": false
                      },
                      "dataFields": {
                        "default": [],
                        "maxItems": 20,
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "pattern": "^[a-z][a-z0-9_]{0,39}$"
                            },
                            "label": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 80
                            },
                            "type": {
                              "type": "string",
                              "enum": ["boolean", "string", "integer", "number"]
                            },
                            "description": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 500
                            },
                            "enum": {
                              "minItems": 1,
                              "maxItems": 20,
                              "type": "array",
                              "items": {
                                "type": "string",
                                "maxLength": 80
                              }
                            }
                          },
                          "required": ["id", "label", "type", "description"],
                          "additionalProperties": false
                        }
                      },
                      "successCriterion": {
                        "anyOf": [
                          {
                            "type": "object",
                            "properties": {
                              "all": {
                                "minItems": 1,
                                "maxItems": 20,
                                "type": "array",
                                "items": {
                                  "anyOf": [
                                    {
                                      "type": "object",
                                      "properties": {
                                        "field": {
                                          "type": "string",
                                          "pattern": "^[a-z][a-z0-9_]{0,39}$"
                                        },
                                        "op": {
                                          "type": "string",
                                          "enum": [
                                            "eq",
                                            "neq",
                                            "contains",
                                            "not_contains",
                                            "gt",
                                            "gte",
                                            "lt",
                                            "lte",
                                            "in",
                                            "exists",
                                            "not_exists"
                                          ]
                                        },
                                        "value": {
                                          "anyOf": [
                                            {
                                              "anyOf": [
                                                {
                                                  "type": "string",
                                                  "maxLength": 500
                                                },
                                                {
                                                  "type": "number"
                                                },
                                                {
                                                  "type": "boolean"
                                                }
                                              ]
                                            },
                                            {
                                              "maxItems": 50,
                                              "type": "array",
                                              "items": {
                                                "anyOf": [
                                                  {
                                                    "type": "string",
                                                    "maxLength": 500
                                                  },
                                                  {
                                                    "type": "number"
                                                  },
                                                  {
                                                    "type": "boolean"
                                                  }
                                                ]
                                              }
                                            }
                                          ]
                                        }
                                      },
                                      "required": ["field", "op"],
                                      "additionalProperties": false
                                    },
                                    {
                                      "type": "object",
                                      "properties": {
                                        "event": {
                                          "type": "string",
                                          "pattern": "^[a-z][a-z0-9_]{0,63}$"
                                        }
                                      },
                                      "required": ["event"],
                                      "additionalProperties": false
                                    }
                                  ]
                                }
                              }
                            },
                            "required": ["all"],
                            "additionalProperties": false
                          },
                          {
                            "type": "object",
                            "properties": {
                              "any": {
                                "minItems": 1,
                                "maxItems": 20,
                                "type": "array",
                                "items": {
                                  "anyOf": [
                                    {
                                      "type": "object",
                                      "properties": {
                                        "field": {
                                          "type": "string",
                                          "pattern": "^[a-z][a-z0-9_]{0,39}$"
                                        },
                                        "op": {
                                          "type": "string",
                                          "enum": [
                                            "eq",
                                            "neq",
                                            "contains",
                                            "not_contains",
                                            "gt",
                                            "gte",
                                            "lt",
                                            "lte",
                                            "in",
                                            "exists",
                                            "not_exists"
                                          ]
                                        },
                                        "value": {
                                          "anyOf": [
                                            {
                                              "anyOf": [
                                                {
                                                  "type": "string",
                                                  "maxLength": 500
                                                },
                                                {
                                                  "type": "number"
                                                },
                                                {
                                                  "type": "boolean"
                                                }
                                              ]
                                            },
                                            {
                                              "maxItems": 50,
                                              "type": "array",
                                              "items": {
                                                "anyOf": [
                                                  {
                                                    "type": "string",
                                                    "maxLength": 500
                                                  },
                                                  {
                                                    "type": "number"
                                                  },
                                                  {
                                                    "type": "boolean"
                                                  }
                                                ]
                                              }
                                            }
                                          ]
                                        }
                                      },
                                      "required": ["field", "op"],
                                      "additionalProperties": false
                                    },
                                    {
                                      "type": "object",
                                      "properties": {
                                        "event": {
                                          "type": "string",
                                          "pattern": "^[a-z][a-z0-9_]{0,63}$"
                                        }
                                      },
                                      "required": ["event"],
                                      "additionalProperties": false
                                    }
                                  ]
                                }
                              }
                            },
                            "required": ["any"],
                            "additionalProperties": false
                          }
                        ]
                      },
                      "transferRules": {
                        "default": [],
                        "maxItems": 10,
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "pattern": "^[a-z][a-z0-9_]{0,39}$"
                            },
                            "name": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 80
                            },
                            "when": {
                              "anyOf": [
                                {
                                  "type": "object",
                                  "properties": {
                                    "all": {
                                      "minItems": 1,
                                      "maxItems": 20,
                                      "type": "array",
                                      "items": {
                                        "anyOf": [
                                          {
                                            "type": "object",
                                            "properties": {
                                              "field": {
                                                "type": "string",
                                                "pattern": "^[a-z][a-z0-9_]{0,39}$"
                                              },
                                              "op": {
                                                "type": "string",
                                                "enum": [
                                                  "eq",
                                                  "neq",
                                                  "contains",
                                                  "not_contains",
                                                  "gt",
                                                  "gte",
                                                  "lt",
                                                  "lte",
                                                  "in",
                                                  "exists",
                                                  "not_exists"
                                                ]
                                              },
                                              "value": {
                                                "anyOf": [
                                                  {
                                                    "anyOf": [
                                                      {
                                                        "type": "string",
                                                        "maxLength": 500
                                                      },
                                                      {
                                                        "type": "number"
                                                      },
                                                      {
                                                        "type": "boolean"
                                                      }
                                                    ]
                                                  },
                                                  {
                                                    "maxItems": 50,
                                                    "type": "array",
                                                    "items": {
                                                      "anyOf": [
                                                        {
                                                          "type": "string",
                                                          "maxLength": 500
                                                        },
                                                        {
                                                          "type": "number"
                                                        },
                                                        {
                                                          "type": "boolean"
                                                        }
                                                      ]
                                                    }
                                                  }
                                                ]
                                              }
                                            },
                                            "required": ["field", "op"],
                                            "additionalProperties": false
                                          },
                                          {
                                            "type": "object",
                                            "properties": {
                                              "event": {
                                                "type": "string",
                                                "pattern": "^[a-z][a-z0-9_]{0,63}$"
                                              }
                                            },
                                            "required": ["event"],
                                            "additionalProperties": false
                                          }
                                        ]
                                      }
                                    }
                                  },
                                  "required": ["all"],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "any": {
                                      "minItems": 1,
                                      "maxItems": 20,
                                      "type": "array",
                                      "items": {
                                        "anyOf": [
                                          {
                                            "type": "object",
                                            "properties": {
                                              "field": {
                                                "type": "string",
                                                "pattern": "^[a-z][a-z0-9_]{0,39}$"
                                              },
                                              "op": {
                                                "type": "string",
                                                "enum": [
                                                  "eq",
                                                  "neq",
                                                  "contains",
                                                  "not_contains",
                                                  "gt",
                                                  "gte",
                                                  "lt",
                                                  "lte",
                                                  "in",
                                                  "exists",
                                                  "not_exists"
                                                ]
                                              },
                                              "value": {
                                                "anyOf": [
                                                  {
                                                    "anyOf": [
                                                      {
                                                        "type": "string",
                                                        "maxLength": 500
                                                      },
                                                      {
                                                        "type": "number"
                                                      },
                                                      {
                                                        "type": "boolean"
                                                      }
                                                    ]
                                                  },
                                                  {
                                                    "maxItems": 50,
                                                    "type": "array",
                                                    "items": {
                                                      "anyOf": [
                                                        {
                                                          "type": "string",
                                                          "maxLength": 500
                                                        },
                                                        {
                                                          "type": "number"
                                                        },
                                                        {
                                                          "type": "boolean"
                                                        }
                                                      ]
                                                    }
                                                  }
                                                ]
                                              }
                                            },
                                            "required": ["field", "op"],
                                            "additionalProperties": false
                                          },
                                          {
                                            "type": "object",
                                            "properties": {
                                              "event": {
                                                "type": "string",
                                                "pattern": "^[a-z][a-z0-9_]{0,63}$"
                                              }
                                            },
                                            "required": ["event"],
                                            "additionalProperties": false
                                          }
                                        ]
                                      }
                                    }
                                  },
                                  "required": ["any"],
                                  "additionalProperties": false
                                }
                              ]
                            },
                            "to": {
                              "type": "string",
                              "pattern": "^\\+[1-9]\\d{6,14}$"
                            },
                            "whisper": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 500
                            },
                            "handoffLine": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 200
                            },
                            "hours": {
                              "type": "object",
                              "properties": {
                                "windows": {
                                  "type": "object",
                                  "properties": {
                                    "sun": {
                                      "maxItems": 4,
                                      "type": "array",
                                      "items": {
                                        "type": "array",
                                        "prefixItems": [
                                          {
                                            "type": "string",
                                            "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                          },
                                          {
                                            "type": "string",
                                            "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                          }
                                        ]
                                      }
                                    },
                                    "mon": {
                                      "maxItems": 4,
                                      "type": "array",
                                      "items": {
                                        "type": "array",
                                        "prefixItems": [
                                          {
                                            "type": "string",
                                            "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                          },
                                          {
                                            "type": "string",
                                            "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                          }
                                        ]
                                      }
                                    },
                                    "tue": {
                                      "maxItems": 4,
                                      "type": "array",
                                      "items": {
                                        "type": "array",
                                        "prefixItems": [
                                          {
                                            "type": "string",
                                            "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                          },
                                          {
                                            "type": "string",
                                            "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                          }
                                        ]
                                      }
                                    },
                                    "wed": {
                                      "maxItems": 4,
                                      "type": "array",
                                      "items": {
                                        "type": "array",
                                        "prefixItems": [
                                          {
                                            "type": "string",
                                            "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                          },
                                          {
                                            "type": "string",
                                            "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                          }
                                        ]
                                      }
                                    },
                                    "thu": {
                                      "maxItems": 4,
                                      "type": "array",
                                      "items": {
                                        "type": "array",
                                        "prefixItems": [
                                          {
                                            "type": "string",
                                            "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                          },
                                          {
                                            "type": "string",
                                            "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                          }
                                        ]
                                      }
                                    },
                                    "fri": {
                                      "maxItems": 4,
                                      "type": "array",
                                      "items": {
                                        "type": "array",
                                        "prefixItems": [
                                          {
                                            "type": "string",
                                            "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                          },
                                          {
                                            "type": "string",
                                            "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                          }
                                        ]
                                      }
                                    },
                                    "sat": {
                                      "maxItems": 4,
                                      "type": "array",
                                      "items": {
                                        "type": "array",
                                        "prefixItems": [
                                          {
                                            "type": "string",
                                            "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                          },
                                          {
                                            "type": "string",
                                            "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                          }
                                        ]
                                      }
                                    }
                                  },
                                  "additionalProperties": false
                                },
                                "timezone": {
                                  "type": "string",
                                  "minLength": 1,
                                  "maxLength": 64
                                }
                              },
                              "required": ["windows", "timezone"],
                              "additionalProperties": false
                            },
                            "fallback": {
                              "default": "callback",
                              "type": "string",
                              "enum": ["callback", "end"]
                            }
                          },
                          "required": ["id", "name", "when", "to", "whisper", "handoffLine"],
                          "additionalProperties": false
                        }
                      }
                    },
                    "required": ["purposeLine"],
                    "additionalProperties": false
                  },
                  "idempotencyKey": {
                    "type": "string",
                    "pattern": "^[A-Za-z0-9_-]{8,128}$"
                  }
                },
                "required": ["orgId", "name", "purpose", "inboxId", "settings", "idempotencyKey"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 128
                    },
                    "orgId": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "purpose": {
                      "type": "string",
                      "enum": ["marketing", "lead_followup", "service"]
                    },
                    "status": {
                      "type": "string",
                      "enum": ["draft", "launching", "running", "paused", "completed", "archived"]
                    },
                    "alwaysOn": {
                      "type": "boolean"
                    },
                    "priority": {
                      "type": "number"
                    },
                    "inboxId": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 128
                    },
                    "settings": {
                      "type": "object",
                      "properties": {
                        "brief": {
                          "default": "",
                          "type": "string",
                          "maxLength": 4000
                        },
                        "purposeLine": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 200
                        },
                        "addressOrFreephone": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 200
                        },
                        "schedule": {
                          "default": {},
                          "type": "object",
                          "properties": {
                            "startAt": {
                              "type": "string",
                              "format": "date-time",
                              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                            },
                            "endAt": {
                              "type": "string",
                              "format": "date-time",
                              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                            },
                            "windows": {
                              "type": "object",
                              "properties": {
                                "sun": {
                                  "maxItems": 4,
                                  "type": "array",
                                  "items": {
                                    "type": "array",
                                    "prefixItems": [
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      },
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      }
                                    ]
                                  }
                                },
                                "mon": {
                                  "maxItems": 4,
                                  "type": "array",
                                  "items": {
                                    "type": "array",
                                    "prefixItems": [
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      },
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      }
                                    ]
                                  }
                                },
                                "tue": {
                                  "maxItems": 4,
                                  "type": "array",
                                  "items": {
                                    "type": "array",
                                    "prefixItems": [
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      },
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      }
                                    ]
                                  }
                                },
                                "wed": {
                                  "maxItems": 4,
                                  "type": "array",
                                  "items": {
                                    "type": "array",
                                    "prefixItems": [
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      },
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      }
                                    ]
                                  }
                                },
                                "thu": {
                                  "maxItems": 4,
                                  "type": "array",
                                  "items": {
                                    "type": "array",
                                    "prefixItems": [
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      },
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      }
                                    ]
                                  }
                                },
                                "fri": {
                                  "maxItems": 4,
                                  "type": "array",
                                  "items": {
                                    "type": "array",
                                    "prefixItems": [
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      },
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      }
                                    ]
                                  }
                                },
                                "sat": {
                                  "maxItems": 4,
                                  "type": "array",
                                  "items": {
                                    "type": "array",
                                    "prefixItems": [
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      },
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      }
                                    ]
                                  }
                                }
                              },
                              "additionalProperties": false
                            }
                          },
                          "additionalProperties": false
                        },
                        "pacing": {
                          "default": {
                            "maxConcurrent": 2,
                            "maxPerHour": 60,
                            "maxNewNumbersPerHour": 30
                          },
                          "type": "object",
                          "properties": {
                            "maxConcurrent": {
                              "default": 2,
                              "type": "integer",
                              "minimum": 1,
                              "maximum": 50
                            },
                            "maxPerHour": {
                              "default": 60,
                              "type": "integer",
                              "minimum": 1,
                              "maximum": 5000
                            },
                            "maxNewNumbersPerHour": {
                              "default": 30,
                              "type": "integer",
                              "minimum": 1,
                              "maximum": 1000
                            }
                          },
                          "required": ["maxConcurrent", "maxPerHour", "maxNewNumbersPerHour"],
                          "additionalProperties": false
                        },
                        "retry": {
                          "default": {
                            "maxAttempts": 3,
                            "retryOn": ["no_answer", "busy", "voicemail"],
                            "gapMinutes": 240
                          },
                          "type": "object",
                          "properties": {
                            "maxAttempts": {
                              "default": 3,
                              "type": "integer",
                              "minimum": 1,
                              "maximum": 3
                            },
                            "retryOn": {
                              "default": ["no_answer", "busy", "voicemail"],
                              "maxItems": 10,
                              "type": "array",
                              "items": {
                                "type": "string",
                                "enum": [
                                  "human",
                                  "voicemail",
                                  "fax",
                                  "no_answer",
                                  "busy",
                                  "failed",
                                  "canceled",
                                  "transferred",
                                  "opted_out",
                                  "abandoned"
                                ]
                              }
                            },
                            "gapMinutes": {
                              "default": 240,
                              "type": "integer",
                              "minimum": 240,
                              "maximum": 10080
                            }
                          },
                          "required": ["maxAttempts", "retryOn", "gapMinutes"],
                          "additionalProperties": false
                        },
                        "dataFields": {
                          "default": [],
                          "maxItems": 20,
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string",
                                "pattern": "^[a-z][a-z0-9_]{0,39}$"
                              },
                              "label": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 80
                              },
                              "type": {
                                "type": "string",
                                "enum": ["boolean", "string", "integer", "number"]
                              },
                              "description": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 500
                              },
                              "enum": {
                                "minItems": 1,
                                "maxItems": 20,
                                "type": "array",
                                "items": {
                                  "type": "string",
                                  "maxLength": 80
                                }
                              }
                            },
                            "required": ["id", "label", "type", "description"],
                            "additionalProperties": false
                          }
                        },
                        "successCriterion": {
                          "anyOf": [
                            {
                              "type": "object",
                              "properties": {
                                "all": {
                                  "minItems": 1,
                                  "maxItems": 20,
                                  "type": "array",
                                  "items": {
                                    "anyOf": [
                                      {
                                        "type": "object",
                                        "properties": {
                                          "field": {
                                            "type": "string",
                                            "pattern": "^[a-z][a-z0-9_]{0,39}$"
                                          },
                                          "op": {
                                            "type": "string",
                                            "enum": [
                                              "eq",
                                              "neq",
                                              "contains",
                                              "not_contains",
                                              "gt",
                                              "gte",
                                              "lt",
                                              "lte",
                                              "in",
                                              "exists",
                                              "not_exists"
                                            ]
                                          },
                                          "value": {
                                            "anyOf": [
                                              {
                                                "anyOf": [
                                                  {
                                                    "type": "string",
                                                    "maxLength": 500
                                                  },
                                                  {
                                                    "type": "number"
                                                  },
                                                  {
                                                    "type": "boolean"
                                                  }
                                                ]
                                              },
                                              {
                                                "maxItems": 50,
                                                "type": "array",
                                                "items": {
                                                  "anyOf": [
                                                    {
                                                      "type": "string",
                                                      "maxLength": 500
                                                    },
                                                    {
                                                      "type": "number"
                                                    },
                                                    {
                                                      "type": "boolean"
                                                    }
                                                  ]
                                                }
                                              }
                                            ]
                                          }
                                        },
                                        "required": ["field", "op"],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "event": {
                                            "type": "string",
                                            "pattern": "^[a-z][a-z0-9_]{0,63}$"
                                          }
                                        },
                                        "required": ["event"],
                                        "additionalProperties": false
                                      }
                                    ]
                                  }
                                }
                              },
                              "required": ["all"],
                              "additionalProperties": false
                            },
                            {
                              "type": "object",
                              "properties": {
                                "any": {
                                  "minItems": 1,
                                  "maxItems": 20,
                                  "type": "array",
                                  "items": {
                                    "anyOf": [
                                      {
                                        "type": "object",
                                        "properties": {
                                          "field": {
                                            "type": "string",
                                            "pattern": "^[a-z][a-z0-9_]{0,39}$"
                                          },
                                          "op": {
                                            "type": "string",
                                            "enum": [
                                              "eq",
                                              "neq",
                                              "contains",
                                              "not_contains",
                                              "gt",
                                              "gte",
                                              "lt",
                                              "lte",
                                              "in",
                                              "exists",
                                              "not_exists"
                                            ]
                                          },
                                          "value": {
                                            "anyOf": [
                                              {
                                                "anyOf": [
                                                  {
                                                    "type": "string",
                                                    "maxLength": 500
                                                  },
                                                  {
                                                    "type": "number"
                                                  },
                                                  {
                                                    "type": "boolean"
                                                  }
                                                ]
                                              },
                                              {
                                                "maxItems": 50,
                                                "type": "array",
                                                "items": {
                                                  "anyOf": [
                                                    {
                                                      "type": "string",
                                                      "maxLength": 500
                                                    },
                                                    {
                                                      "type": "number"
                                                    },
                                                    {
                                                      "type": "boolean"
                                                    }
                                                  ]
                                                }
                                              }
                                            ]
                                          }
                                        },
                                        "required": ["field", "op"],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "event": {
                                            "type": "string",
                                            "pattern": "^[a-z][a-z0-9_]{0,63}$"
                                          }
                                        },
                                        "required": ["event"],
                                        "additionalProperties": false
                                      }
                                    ]
                                  }
                                }
                              },
                              "required": ["any"],
                              "additionalProperties": false
                            }
                          ]
                        },
                        "transferRules": {
                          "default": [],
                          "maxItems": 10,
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string",
                                "pattern": "^[a-z][a-z0-9_]{0,39}$"
                              },
                              "name": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 80
                              },
                              "when": {
                                "anyOf": [
                                  {
                                    "type": "object",
                                    "properties": {
                                      "all": {
                                        "minItems": 1,
                                        "maxItems": 20,
                                        "type": "array",
                                        "items": {
                                          "anyOf": [
                                            {
                                              "type": "object",
                                              "properties": {
                                                "field": {
                                                  "type": "string",
                                                  "pattern": "^[a-z][a-z0-9_]{0,39}$"
                                                },
                                                "op": {
                                                  "type": "string",
                                                  "enum": [
                                                    "eq",
                                                    "neq",
                                                    "contains",
                                                    "not_contains",
                                                    "gt",
                                                    "gte",
                                                    "lt",
                                                    "lte",
                                                    "in",
                                                    "exists",
                                                    "not_exists"
                                                  ]
                                                },
                                                "value": {
                                                  "anyOf": [
                                                    {
                                                      "anyOf": [
                                                        {
                                                          "type": "string",
                                                          "maxLength": 500
                                                        },
                                                        {
                                                          "type": "number"
                                                        },
                                                        {
                                                          "type": "boolean"
                                                        }
                                                      ]
                                                    },
                                                    {
                                                      "maxItems": 50,
                                                      "type": "array",
                                                      "items": {
                                                        "anyOf": [
                                                          {
                                                            "type": "string",
                                                            "maxLength": 500
                                                          },
                                                          {
                                                            "type": "number"
                                                          },
                                                          {
                                                            "type": "boolean"
                                                          }
                                                        ]
                                                      }
                                                    }
                                                  ]
                                                }
                                              },
                                              "required": ["field", "op"],
                                              "additionalProperties": false
                                            },
                                            {
                                              "type": "object",
                                              "properties": {
                                                "event": {
                                                  "type": "string",
                                                  "pattern": "^[a-z][a-z0-9_]{0,63}$"
                                                }
                                              },
                                              "required": ["event"],
                                              "additionalProperties": false
                                            }
                                          ]
                                        }
                                      }
                                    },
                                    "required": ["all"],
                                    "additionalProperties": false
                                  },
                                  {
                                    "type": "object",
                                    "properties": {
                                      "any": {
                                        "minItems": 1,
                                        "maxItems": 20,
                                        "type": "array",
                                        "items": {
                                          "anyOf": [
                                            {
                                              "type": "object",
                                              "properties": {
                                                "field": {
                                                  "type": "string",
                                                  "pattern": "^[a-z][a-z0-9_]{0,39}$"
                                                },
                                                "op": {
                                                  "type": "string",
                                                  "enum": [
                                                    "eq",
                                                    "neq",
                                                    "contains",
                                                    "not_contains",
                                                    "gt",
                                                    "gte",
                                                    "lt",
                                                    "lte",
                                                    "in",
                                                    "exists",
                                                    "not_exists"
                                                  ]
                                                },
                                                "value": {
                                                  "anyOf": [
                                                    {
                                                      "anyOf": [
                                                        {
                                                          "type": "string",
                                                          "maxLength": 500
                                                        },
                                                        {
                                                          "type": "number"
                                                        },
                                                        {
                                                          "type": "boolean"
                                                        }
                                                      ]
                                                    },
                                                    {
                                                      "maxItems": 50,
                                                      "type": "array",
                                                      "items": {
                                                        "anyOf": [
                                                          {
                                                            "type": "string",
                                                            "maxLength": 500
                                                          },
                                                          {
                                                            "type": "number"
                                                          },
                                                          {
                                                            "type": "boolean"
                                                          }
                                                        ]
                                                      }
                                                    }
                                                  ]
                                                }
                                              },
                                              "required": ["field", "op"],
                                              "additionalProperties": false
                                            },
                                            {
                                              "type": "object",
                                              "properties": {
                                                "event": {
                                                  "type": "string",
                                                  "pattern": "^[a-z][a-z0-9_]{0,63}$"
                                                }
                                              },
                                              "required": ["event"],
                                              "additionalProperties": false
                                            }
                                          ]
                                        }
                                      }
                                    },
                                    "required": ["any"],
                                    "additionalProperties": false
                                  }
                                ]
                              },
                              "to": {
                                "type": "string",
                                "pattern": "^\\+[1-9]\\d{6,14}$"
                              },
                              "whisper": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 500
                              },
                              "handoffLine": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 200
                              },
                              "hours": {
                                "type": "object",
                                "properties": {
                                  "windows": {
                                    "type": "object",
                                    "properties": {
                                      "sun": {
                                        "maxItems": 4,
                                        "type": "array",
                                        "items": {
                                          "type": "array",
                                          "prefixItems": [
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            },
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            }
                                          ]
                                        }
                                      },
                                      "mon": {
                                        "maxItems": 4,
                                        "type": "array",
                                        "items": {
                                          "type": "array",
                                          "prefixItems": [
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            },
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            }
                                          ]
                                        }
                                      },
                                      "tue": {
                                        "maxItems": 4,
                                        "type": "array",
                                        "items": {
                                          "type": "array",
                                          "prefixItems": [
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            },
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            }
                                          ]
                                        }
                                      },
                                      "wed": {
                                        "maxItems": 4,
                                        "type": "array",
                                        "items": {
                                          "type": "array",
                                          "prefixItems": [
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            },
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            }
                                          ]
                                        }
                                      },
                                      "thu": {
                                        "maxItems": 4,
                                        "type": "array",
                                        "items": {
                                          "type": "array",
                                          "prefixItems": [
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            },
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            }
                                          ]
                                        }
                                      },
                                      "fri": {
                                        "maxItems": 4,
                                        "type": "array",
                                        "items": {
                                          "type": "array",
                                          "prefixItems": [
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            },
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            }
                                          ]
                                        }
                                      },
                                      "sat": {
                                        "maxItems": 4,
                                        "type": "array",
                                        "items": {
                                          "type": "array",
                                          "prefixItems": [
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            },
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            }
                                          ]
                                        }
                                      }
                                    },
                                    "additionalProperties": false
                                  },
                                  "timezone": {
                                    "type": "string",
                                    "minLength": 1,
                                    "maxLength": 64
                                  }
                                },
                                "required": ["windows", "timezone"],
                                "additionalProperties": false
                              },
                              "fallback": {
                                "default": "callback",
                                "type": "string",
                                "enum": ["callback", "end"]
                              }
                            },
                            "required": [
                              "id",
                              "name",
                              "when",
                              "to",
                              "whisper",
                              "handoffLine",
                              "fallback"
                            ],
                            "additionalProperties": false
                          }
                        }
                      },
                      "required": [
                        "brief",
                        "purposeLine",
                        "schedule",
                        "pacing",
                        "retry",
                        "dataFields",
                        "transferRules"
                      ],
                      "additionalProperties": false
                    },
                    "requiredVariables": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "settingsConfirmedBy": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "pausedReason": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "createdBy": {
                      "type": "string"
                    },
                    "launchedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "completedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "createdAt": {
                      "type": "string"
                    },
                    "updatedAt": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "id",
                    "orgId",
                    "name",
                    "purpose",
                    "status",
                    "alwaysOn",
                    "priority",
                    "inboxId",
                    "settings",
                    "requiredVariables",
                    "settingsConfirmedBy",
                    "pausedReason",
                    "createdBy",
                    "launchedAt",
                    "completedAt",
                    "createdAt",
                    "updatedAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      },
      "get": {
        "operationId": "outbound-campaigns-list",
        "summary": "List outbound campaigns and request counts",
        "tags": ["Outbound"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "status",
            "schema": {
              "type": "string",
              "enum": ["draft", "launching", "running", "paused", "completed", "archived"]
            }
          },
          {
            "in": "query",
            "name": "limit",
            "schema": {
              "default": 50,
              "type": "integer",
              "minimum": 1,
              "maximum": 100
            }
          },
          {
            "in": "query",
            "name": "offset",
            "schema": {
              "default": 0,
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "campaigns": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 128
                          },
                          "orgId": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "purpose": {
                            "type": "string",
                            "enum": ["marketing", "lead_followup", "service"]
                          },
                          "status": {
                            "type": "string",
                            "enum": [
                              "draft",
                              "launching",
                              "running",
                              "paused",
                              "completed",
                              "archived"
                            ]
                          },
                          "alwaysOn": {
                            "type": "boolean"
                          },
                          "priority": {
                            "type": "number"
                          },
                          "inboxId": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 128
                          },
                          "settings": {
                            "type": "object",
                            "properties": {
                              "brief": {
                                "default": "",
                                "type": "string",
                                "maxLength": 4000
                              },
                              "purposeLine": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 200
                              },
                              "addressOrFreephone": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 200
                              },
                              "schedule": {
                                "default": {},
                                "type": "object",
                                "properties": {
                                  "startAt": {
                                    "type": "string",
                                    "format": "date-time",
                                    "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                                  },
                                  "endAt": {
                                    "type": "string",
                                    "format": "date-time",
                                    "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                                  },
                                  "windows": {
                                    "type": "object",
                                    "properties": {
                                      "sun": {
                                        "maxItems": 4,
                                        "type": "array",
                                        "items": {
                                          "type": "array",
                                          "prefixItems": [
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            },
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            }
                                          ]
                                        }
                                      },
                                      "mon": {
                                        "maxItems": 4,
                                        "type": "array",
                                        "items": {
                                          "type": "array",
                                          "prefixItems": [
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            },
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            }
                                          ]
                                        }
                                      },
                                      "tue": {
                                        "maxItems": 4,
                                        "type": "array",
                                        "items": {
                                          "type": "array",
                                          "prefixItems": [
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            },
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            }
                                          ]
                                        }
                                      },
                                      "wed": {
                                        "maxItems": 4,
                                        "type": "array",
                                        "items": {
                                          "type": "array",
                                          "prefixItems": [
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            },
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            }
                                          ]
                                        }
                                      },
                                      "thu": {
                                        "maxItems": 4,
                                        "type": "array",
                                        "items": {
                                          "type": "array",
                                          "prefixItems": [
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            },
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            }
                                          ]
                                        }
                                      },
                                      "fri": {
                                        "maxItems": 4,
                                        "type": "array",
                                        "items": {
                                          "type": "array",
                                          "prefixItems": [
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            },
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            }
                                          ]
                                        }
                                      },
                                      "sat": {
                                        "maxItems": 4,
                                        "type": "array",
                                        "items": {
                                          "type": "array",
                                          "prefixItems": [
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            },
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            }
                                          ]
                                        }
                                      }
                                    },
                                    "additionalProperties": false
                                  }
                                },
                                "additionalProperties": false
                              },
                              "pacing": {
                                "default": {
                                  "maxConcurrent": 2,
                                  "maxPerHour": 60,
                                  "maxNewNumbersPerHour": 30
                                },
                                "type": "object",
                                "properties": {
                                  "maxConcurrent": {
                                    "default": 2,
                                    "type": "integer",
                                    "minimum": 1,
                                    "maximum": 50
                                  },
                                  "maxPerHour": {
                                    "default": 60,
                                    "type": "integer",
                                    "minimum": 1,
                                    "maximum": 5000
                                  },
                                  "maxNewNumbersPerHour": {
                                    "default": 30,
                                    "type": "integer",
                                    "minimum": 1,
                                    "maximum": 1000
                                  }
                                },
                                "required": ["maxConcurrent", "maxPerHour", "maxNewNumbersPerHour"],
                                "additionalProperties": false
                              },
                              "retry": {
                                "default": {
                                  "maxAttempts": 3,
                                  "retryOn": ["no_answer", "busy", "voicemail"],
                                  "gapMinutes": 240
                                },
                                "type": "object",
                                "properties": {
                                  "maxAttempts": {
                                    "default": 3,
                                    "type": "integer",
                                    "minimum": 1,
                                    "maximum": 3
                                  },
                                  "retryOn": {
                                    "default": ["no_answer", "busy", "voicemail"],
                                    "maxItems": 10,
                                    "type": "array",
                                    "items": {
                                      "type": "string",
                                      "enum": [
                                        "human",
                                        "voicemail",
                                        "fax",
                                        "no_answer",
                                        "busy",
                                        "failed",
                                        "canceled",
                                        "transferred",
                                        "opted_out",
                                        "abandoned"
                                      ]
                                    }
                                  },
                                  "gapMinutes": {
                                    "default": 240,
                                    "type": "integer",
                                    "minimum": 240,
                                    "maximum": 10080
                                  }
                                },
                                "required": ["maxAttempts", "retryOn", "gapMinutes"],
                                "additionalProperties": false
                              },
                              "dataFields": {
                                "default": [],
                                "maxItems": 20,
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "id": {
                                      "type": "string",
                                      "pattern": "^[a-z][a-z0-9_]{0,39}$"
                                    },
                                    "label": {
                                      "type": "string",
                                      "minLength": 1,
                                      "maxLength": 80
                                    },
                                    "type": {
                                      "type": "string",
                                      "enum": ["boolean", "string", "integer", "number"]
                                    },
                                    "description": {
                                      "type": "string",
                                      "minLength": 1,
                                      "maxLength": 500
                                    },
                                    "enum": {
                                      "minItems": 1,
                                      "maxItems": 20,
                                      "type": "array",
                                      "items": {
                                        "type": "string",
                                        "maxLength": 80
                                      }
                                    }
                                  },
                                  "required": ["id", "label", "type", "description"],
                                  "additionalProperties": false
                                }
                              },
                              "successCriterion": {
                                "anyOf": [
                                  {
                                    "type": "object",
                                    "properties": {
                                      "all": {
                                        "minItems": 1,
                                        "maxItems": 20,
                                        "type": "array",
                                        "items": {
                                          "anyOf": [
                                            {
                                              "type": "object",
                                              "properties": {
                                                "field": {
                                                  "type": "string",
                                                  "pattern": "^[a-z][a-z0-9_]{0,39}$"
                                                },
                                                "op": {
                                                  "type": "string",
                                                  "enum": [
                                                    "eq",
                                                    "neq",
                                                    "contains",
                                                    "not_contains",
                                                    "gt",
                                                    "gte",
                                                    "lt",
                                                    "lte",
                                                    "in",
                                                    "exists",
                                                    "not_exists"
                                                  ]
                                                },
                                                "value": {
                                                  "anyOf": [
                                                    {
                                                      "anyOf": [
                                                        {
                                                          "type": "string",
                                                          "maxLength": 500
                                                        },
                                                        {
                                                          "type": "number"
                                                        },
                                                        {
                                                          "type": "boolean"
                                                        }
                                                      ]
                                                    },
                                                    {
                                                      "maxItems": 50,
                                                      "type": "array",
                                                      "items": {
                                                        "anyOf": [
                                                          {
                                                            "type": "string",
                                                            "maxLength": 500
                                                          },
                                                          {
                                                            "type": "number"
                                                          },
                                                          {
                                                            "type": "boolean"
                                                          }
                                                        ]
                                                      }
                                                    }
                                                  ]
                                                }
                                              },
                                              "required": ["field", "op"],
                                              "additionalProperties": false
                                            },
                                            {
                                              "type": "object",
                                              "properties": {
                                                "event": {
                                                  "type": "string",
                                                  "pattern": "^[a-z][a-z0-9_]{0,63}$"
                                                }
                                              },
                                              "required": ["event"],
                                              "additionalProperties": false
                                            }
                                          ]
                                        }
                                      }
                                    },
                                    "required": ["all"],
                                    "additionalProperties": false
                                  },
                                  {
                                    "type": "object",
                                    "properties": {
                                      "any": {
                                        "minItems": 1,
                                        "maxItems": 20,
                                        "type": "array",
                                        "items": {
                                          "anyOf": [
                                            {
                                              "type": "object",
                                              "properties": {
                                                "field": {
                                                  "type": "string",
                                                  "pattern": "^[a-z][a-z0-9_]{0,39}$"
                                                },
                                                "op": {
                                                  "type": "string",
                                                  "enum": [
                                                    "eq",
                                                    "neq",
                                                    "contains",
                                                    "not_contains",
                                                    "gt",
                                                    "gte",
                                                    "lt",
                                                    "lte",
                                                    "in",
                                                    "exists",
                                                    "not_exists"
                                                  ]
                                                },
                                                "value": {
                                                  "anyOf": [
                                                    {
                                                      "anyOf": [
                                                        {
                                                          "type": "string",
                                                          "maxLength": 500
                                                        },
                                                        {
                                                          "type": "number"
                                                        },
                                                        {
                                                          "type": "boolean"
                                                        }
                                                      ]
                                                    },
                                                    {
                                                      "maxItems": 50,
                                                      "type": "array",
                                                      "items": {
                                                        "anyOf": [
                                                          {
                                                            "type": "string",
                                                            "maxLength": 500
                                                          },
                                                          {
                                                            "type": "number"
                                                          },
                                                          {
                                                            "type": "boolean"
                                                          }
                                                        ]
                                                      }
                                                    }
                                                  ]
                                                }
                                              },
                                              "required": ["field", "op"],
                                              "additionalProperties": false
                                            },
                                            {
                                              "type": "object",
                                              "properties": {
                                                "event": {
                                                  "type": "string",
                                                  "pattern": "^[a-z][a-z0-9_]{0,63}$"
                                                }
                                              },
                                              "required": ["event"],
                                              "additionalProperties": false
                                            }
                                          ]
                                        }
                                      }
                                    },
                                    "required": ["any"],
                                    "additionalProperties": false
                                  }
                                ]
                              },
                              "transferRules": {
                                "default": [],
                                "maxItems": 10,
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "id": {
                                      "type": "string",
                                      "pattern": "^[a-z][a-z0-9_]{0,39}$"
                                    },
                                    "name": {
                                      "type": "string",
                                      "minLength": 1,
                                      "maxLength": 80
                                    },
                                    "when": {
                                      "anyOf": [
                                        {
                                          "type": "object",
                                          "properties": {
                                            "all": {
                                              "minItems": 1,
                                              "maxItems": 20,
                                              "type": "array",
                                              "items": {
                                                "anyOf": [
                                                  {
                                                    "type": "object",
                                                    "properties": {
                                                      "field": {
                                                        "type": "string",
                                                        "pattern": "^[a-z][a-z0-9_]{0,39}$"
                                                      },
                                                      "op": {
                                                        "type": "string",
                                                        "enum": [
                                                          "eq",
                                                          "neq",
                                                          "contains",
                                                          "not_contains",
                                                          "gt",
                                                          "gte",
                                                          "lt",
                                                          "lte",
                                                          "in",
                                                          "exists",
                                                          "not_exists"
                                                        ]
                                                      },
                                                      "value": {
                                                        "anyOf": [
                                                          {
                                                            "anyOf": [
                                                              {
                                                                "type": "string",
                                                                "maxLength": 500
                                                              },
                                                              {
                                                                "type": "number"
                                                              },
                                                              {
                                                                "type": "boolean"
                                                              }
                                                            ]
                                                          },
                                                          {
                                                            "maxItems": 50,
                                                            "type": "array",
                                                            "items": {
                                                              "anyOf": [
                                                                {
                                                                  "type": "string",
                                                                  "maxLength": 500
                                                                },
                                                                {
                                                                  "type": "number"
                                                                },
                                                                {
                                                                  "type": "boolean"
                                                                }
                                                              ]
                                                            }
                                                          }
                                                        ]
                                                      }
                                                    },
                                                    "required": ["field", "op"],
                                                    "additionalProperties": false
                                                  },
                                                  {
                                                    "type": "object",
                                                    "properties": {
                                                      "event": {
                                                        "type": "string",
                                                        "pattern": "^[a-z][a-z0-9_]{0,63}$"
                                                      }
                                                    },
                                                    "required": ["event"],
                                                    "additionalProperties": false
                                                  }
                                                ]
                                              }
                                            }
                                          },
                                          "required": ["all"],
                                          "additionalProperties": false
                                        },
                                        {
                                          "type": "object",
                                          "properties": {
                                            "any": {
                                              "minItems": 1,
                                              "maxItems": 20,
                                              "type": "array",
                                              "items": {
                                                "anyOf": [
                                                  {
                                                    "type": "object",
                                                    "properties": {
                                                      "field": {
                                                        "type": "string",
                                                        "pattern": "^[a-z][a-z0-9_]{0,39}$"
                                                      },
                                                      "op": {
                                                        "type": "string",
                                                        "enum": [
                                                          "eq",
                                                          "neq",
                                                          "contains",
                                                          "not_contains",
                                                          "gt",
                                                          "gte",
                                                          "lt",
                                                          "lte",
                                                          "in",
                                                          "exists",
                                                          "not_exists"
                                                        ]
                                                      },
                                                      "value": {
                                                        "anyOf": [
                                                          {
                                                            "anyOf": [
                                                              {
                                                                "type": "string",
                                                                "maxLength": 500
                                                              },
                                                              {
                                                                "type": "number"
                                                              },
                                                              {
                                                                "type": "boolean"
                                                              }
                                                            ]
                                                          },
                                                          {
                                                            "maxItems": 50,
                                                            "type": "array",
                                                            "items": {
                                                              "anyOf": [
                                                                {
                                                                  "type": "string",
                                                                  "maxLength": 500
                                                                },
                                                                {
                                                                  "type": "number"
                                                                },
                                                                {
                                                                  "type": "boolean"
                                                                }
                                                              ]
                                                            }
                                                          }
                                                        ]
                                                      }
                                                    },
                                                    "required": ["field", "op"],
                                                    "additionalProperties": false
                                                  },
                                                  {
                                                    "type": "object",
                                                    "properties": {
                                                      "event": {
                                                        "type": "string",
                                                        "pattern": "^[a-z][a-z0-9_]{0,63}$"
                                                      }
                                                    },
                                                    "required": ["event"],
                                                    "additionalProperties": false
                                                  }
                                                ]
                                              }
                                            }
                                          },
                                          "required": ["any"],
                                          "additionalProperties": false
                                        }
                                      ]
                                    },
                                    "to": {
                                      "type": "string",
                                      "pattern": "^\\+[1-9]\\d{6,14}$"
                                    },
                                    "whisper": {
                                      "type": "string",
                                      "minLength": 1,
                                      "maxLength": 500
                                    },
                                    "handoffLine": {
                                      "type": "string",
                                      "minLength": 1,
                                      "maxLength": 200
                                    },
                                    "hours": {
                                      "type": "object",
                                      "properties": {
                                        "windows": {
                                          "type": "object",
                                          "properties": {
                                            "sun": {
                                              "maxItems": 4,
                                              "type": "array",
                                              "items": {
                                                "type": "array",
                                                "prefixItems": [
                                                  {
                                                    "type": "string",
                                                    "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                                  },
                                                  {
                                                    "type": "string",
                                                    "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                                  }
                                                ]
                                              }
                                            },
                                            "mon": {
                                              "maxItems": 4,
                                              "type": "array",
                                              "items": {
                                                "type": "array",
                                                "prefixItems": [
                                                  {
                                                    "type": "string",
                                                    "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                                  },
                                                  {
                                                    "type": "string",
                                                    "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                                  }
                                                ]
                                              }
                                            },
                                            "tue": {
                                              "maxItems": 4,
                                              "type": "array",
                                              "items": {
                                                "type": "array",
                                                "prefixItems": [
                                                  {
                                                    "type": "string",
                                                    "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                                  },
                                                  {
                                                    "type": "string",
                                                    "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                                  }
                                                ]
                                              }
                                            },
                                            "wed": {
                                              "maxItems": 4,
                                              "type": "array",
                                              "items": {
                                                "type": "array",
                                                "prefixItems": [
                                                  {
                                                    "type": "string",
                                                    "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                                  },
                                                  {
                                                    "type": "string",
                                                    "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                                  }
                                                ]
                                              }
                                            },
                                            "thu": {
                                              "maxItems": 4,
                                              "type": "array",
                                              "items": {
                                                "type": "array",
                                                "prefixItems": [
                                                  {
                                                    "type": "string",
                                                    "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                                  },
                                                  {
                                                    "type": "string",
                                                    "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                                  }
                                                ]
                                              }
                                            },
                                            "fri": {
                                              "maxItems": 4,
                                              "type": "array",
                                              "items": {
                                                "type": "array",
                                                "prefixItems": [
                                                  {
                                                    "type": "string",
                                                    "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                                  },
                                                  {
                                                    "type": "string",
                                                    "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                                  }
                                                ]
                                              }
                                            },
                                            "sat": {
                                              "maxItems": 4,
                                              "type": "array",
                                              "items": {
                                                "type": "array",
                                                "prefixItems": [
                                                  {
                                                    "type": "string",
                                                    "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                                  },
                                                  {
                                                    "type": "string",
                                                    "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                                  }
                                                ]
                                              }
                                            }
                                          },
                                          "additionalProperties": false
                                        },
                                        "timezone": {
                                          "type": "string",
                                          "minLength": 1,
                                          "maxLength": 64
                                        }
                                      },
                                      "required": ["windows", "timezone"],
                                      "additionalProperties": false
                                    },
                                    "fallback": {
                                      "default": "callback",
                                      "type": "string",
                                      "enum": ["callback", "end"]
                                    }
                                  },
                                  "required": [
                                    "id",
                                    "name",
                                    "when",
                                    "to",
                                    "whisper",
                                    "handoffLine",
                                    "fallback"
                                  ],
                                  "additionalProperties": false
                                }
                              }
                            },
                            "required": [
                              "brief",
                              "purposeLine",
                              "schedule",
                              "pacing",
                              "retry",
                              "dataFields",
                              "transferRules"
                            ],
                            "additionalProperties": false
                          },
                          "requiredVariables": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "settingsConfirmedBy": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "pausedReason": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "createdBy": {
                            "type": "string"
                          },
                          "launchedAt": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "completedAt": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "createdAt": {
                            "type": "string"
                          },
                          "updatedAt": {
                            "type": "string"
                          },
                          "variants": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "id": {
                                  "type": "string",
                                  "minLength": 1,
                                  "maxLength": 128
                                },
                                "campaignId": {
                                  "type": "string",
                                  "minLength": 1,
                                  "maxLength": 128
                                },
                                "orgId": {
                                  "type": "string"
                                },
                                "key": {
                                  "type": "string",
                                  "enum": ["A", "B", "C"]
                                },
                                "name": {
                                  "type": "string"
                                },
                                "weight": {
                                  "type": "number"
                                },
                                "baseAgentId": {
                                  "type": "string",
                                  "minLength": 1,
                                  "maxLength": 128
                                },
                                "overrides": {
                                  "type": "object",
                                  "properties": {
                                    "greeting": {
                                      "type": "string",
                                      "maxLength": 500
                                    },
                                    "promptAppend": {
                                      "type": "string",
                                      "maxLength": 4000
                                    },
                                    "voiceId": {
                                      "type": "string",
                                      "maxLength": 100
                                    }
                                  },
                                  "additionalProperties": false
                                },
                                "elevenLabsAgentId": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "elevenLabsWorkspace": {
                                  "anyOf": [
                                    {
                                      "type": "string",
                                      "enum": ["platform", "byok"]
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "snapshotHash": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "status": {
                                  "type": "string",
                                  "enum": ["draft", "active", "stopped", "retired"]
                                },
                                "retiredAt": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "createdAt": {
                                  "type": "string"
                                },
                                "updatedAt": {
                                  "type": "string"
                                }
                              },
                              "required": [
                                "id",
                                "campaignId",
                                "orgId",
                                "key",
                                "name",
                                "weight",
                                "baseAgentId",
                                "overrides",
                                "elevenLabsAgentId",
                                "elevenLabsWorkspace",
                                "snapshotHash",
                                "status",
                                "retiredAt",
                                "createdAt",
                                "updatedAt"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "counts": {
                            "type": "object",
                            "propertyNames": {
                              "type": "string",
                              "enum": [
                                "queued",
                                "dialing",
                                "in_call",
                                "completed",
                                "skipped",
                                "canceled",
                                "exhausted",
                                "failed"
                              ]
                            },
                            "additionalProperties": {
                              "type": "number"
                            }
                          }
                        },
                        "required": [
                          "id",
                          "orgId",
                          "name",
                          "purpose",
                          "status",
                          "alwaysOn",
                          "priority",
                          "inboxId",
                          "settings",
                          "requiredVariables",
                          "settingsConfirmedBy",
                          "pausedReason",
                          "createdBy",
                          "launchedAt",
                          "completedAt",
                          "createdAt",
                          "updatedAt",
                          "variants",
                          "counts"
                        ],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": ["campaigns"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/outbound/campaigns/{id}/update": {
      "post": {
        "operationId": "outbound-campaigns-update",
        "summary": "Update a draft or paused campaign",
        "tags": ["Outbound"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 128
            },
            "required": true
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 120
                  },
                  "settings": {
                    "type": "object",
                    "properties": {
                      "brief": {
                        "type": "string",
                        "maxLength": 4000
                      },
                      "purposeLine": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 200
                      },
                      "addressOrFreephone": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 200
                      },
                      "schedule": {
                        "type": "object",
                        "properties": {
                          "startAt": {
                            "type": "string",
                            "format": "date-time",
                            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                          },
                          "endAt": {
                            "type": "string",
                            "format": "date-time",
                            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                          },
                          "windows": {
                            "type": "object",
                            "properties": {
                              "sun": {
                                "maxItems": 4,
                                "type": "array",
                                "items": {
                                  "type": "array",
                                  "prefixItems": [
                                    {
                                      "type": "string",
                                      "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                    },
                                    {
                                      "type": "string",
                                      "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                    }
                                  ]
                                }
                              },
                              "mon": {
                                "maxItems": 4,
                                "type": "array",
                                "items": {
                                  "type": "array",
                                  "prefixItems": [
                                    {
                                      "type": "string",
                                      "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                    },
                                    {
                                      "type": "string",
                                      "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                    }
                                  ]
                                }
                              },
                              "tue": {
                                "maxItems": 4,
                                "type": "array",
                                "items": {
                                  "type": "array",
                                  "prefixItems": [
                                    {
                                      "type": "string",
                                      "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                    },
                                    {
                                      "type": "string",
                                      "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                    }
                                  ]
                                }
                              },
                              "wed": {
                                "maxItems": 4,
                                "type": "array",
                                "items": {
                                  "type": "array",
                                  "prefixItems": [
                                    {
                                      "type": "string",
                                      "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                    },
                                    {
                                      "type": "string",
                                      "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                    }
                                  ]
                                }
                              },
                              "thu": {
                                "maxItems": 4,
                                "type": "array",
                                "items": {
                                  "type": "array",
                                  "prefixItems": [
                                    {
                                      "type": "string",
                                      "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                    },
                                    {
                                      "type": "string",
                                      "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                    }
                                  ]
                                }
                              },
                              "fri": {
                                "maxItems": 4,
                                "type": "array",
                                "items": {
                                  "type": "array",
                                  "prefixItems": [
                                    {
                                      "type": "string",
                                      "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                    },
                                    {
                                      "type": "string",
                                      "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                    }
                                  ]
                                }
                              },
                              "sat": {
                                "maxItems": 4,
                                "type": "array",
                                "items": {
                                  "type": "array",
                                  "prefixItems": [
                                    {
                                      "type": "string",
                                      "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                    },
                                    {
                                      "type": "string",
                                      "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                    }
                                  ]
                                }
                              }
                            },
                            "additionalProperties": false
                          }
                        },
                        "additionalProperties": false
                      },
                      "pacing": {
                        "type": "object",
                        "properties": {
                          "maxConcurrent": {
                            "type": "integer",
                            "minimum": 1,
                            "maximum": 50
                          },
                          "maxPerHour": {
                            "type": "integer",
                            "minimum": 1,
                            "maximum": 5000
                          },
                          "maxNewNumbersPerHour": {
                            "type": "integer",
                            "minimum": 1,
                            "maximum": 1000
                          }
                        },
                        "additionalProperties": false
                      },
                      "retry": {
                        "type": "object",
                        "properties": {
                          "maxAttempts": {
                            "type": "integer",
                            "minimum": 1,
                            "maximum": 3
                          },
                          "retryOn": {
                            "maxItems": 10,
                            "type": "array",
                            "items": {
                              "type": "string",
                              "enum": [
                                "human",
                                "voicemail",
                                "fax",
                                "no_answer",
                                "busy",
                                "failed",
                                "canceled",
                                "transferred",
                                "opted_out",
                                "abandoned"
                              ]
                            }
                          },
                          "gapMinutes": {
                            "type": "integer",
                            "minimum": 240,
                            "maximum": 10080
                          }
                        },
                        "additionalProperties": false
                      },
                      "dataFields": {
                        "maxItems": 20,
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "pattern": "^[a-z][a-z0-9_]{0,39}$"
                            },
                            "label": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 80
                            },
                            "type": {
                              "type": "string",
                              "enum": ["boolean", "string", "integer", "number"]
                            },
                            "description": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 500
                            },
                            "enum": {
                              "minItems": 1,
                              "maxItems": 20,
                              "type": "array",
                              "items": {
                                "type": "string",
                                "maxLength": 80
                              }
                            }
                          },
                          "required": ["id", "label", "type", "description"],
                          "additionalProperties": false
                        }
                      },
                      "successCriterion": {
                        "anyOf": [
                          {
                            "type": "object",
                            "properties": {
                              "all": {
                                "minItems": 1,
                                "maxItems": 20,
                                "type": "array",
                                "items": {
                                  "anyOf": [
                                    {
                                      "type": "object",
                                      "properties": {
                                        "field": {
                                          "type": "string",
                                          "pattern": "^[a-z][a-z0-9_]{0,39}$"
                                        },
                                        "op": {
                                          "type": "string",
                                          "enum": [
                                            "eq",
                                            "neq",
                                            "contains",
                                            "not_contains",
                                            "gt",
                                            "gte",
                                            "lt",
                                            "lte",
                                            "in",
                                            "exists",
                                            "not_exists"
                                          ]
                                        },
                                        "value": {
                                          "anyOf": [
                                            {
                                              "anyOf": [
                                                {
                                                  "type": "string",
                                                  "maxLength": 500
                                                },
                                                {
                                                  "type": "number"
                                                },
                                                {
                                                  "type": "boolean"
                                                }
                                              ]
                                            },
                                            {
                                              "maxItems": 50,
                                              "type": "array",
                                              "items": {
                                                "anyOf": [
                                                  {
                                                    "type": "string",
                                                    "maxLength": 500
                                                  },
                                                  {
                                                    "type": "number"
                                                  },
                                                  {
                                                    "type": "boolean"
                                                  }
                                                ]
                                              }
                                            }
                                          ]
                                        }
                                      },
                                      "required": ["field", "op"],
                                      "additionalProperties": false
                                    },
                                    {
                                      "type": "object",
                                      "properties": {
                                        "event": {
                                          "type": "string",
                                          "pattern": "^[a-z][a-z0-9_]{0,63}$"
                                        }
                                      },
                                      "required": ["event"],
                                      "additionalProperties": false
                                    }
                                  ]
                                }
                              }
                            },
                            "required": ["all"],
                            "additionalProperties": false
                          },
                          {
                            "type": "object",
                            "properties": {
                              "any": {
                                "minItems": 1,
                                "maxItems": 20,
                                "type": "array",
                                "items": {
                                  "anyOf": [
                                    {
                                      "type": "object",
                                      "properties": {
                                        "field": {
                                          "type": "string",
                                          "pattern": "^[a-z][a-z0-9_]{0,39}$"
                                        },
                                        "op": {
                                          "type": "string",
                                          "enum": [
                                            "eq",
                                            "neq",
                                            "contains",
                                            "not_contains",
                                            "gt",
                                            "gte",
                                            "lt",
                                            "lte",
                                            "in",
                                            "exists",
                                            "not_exists"
                                          ]
                                        },
                                        "value": {
                                          "anyOf": [
                                            {
                                              "anyOf": [
                                                {
                                                  "type": "string",
                                                  "maxLength": 500
                                                },
                                                {
                                                  "type": "number"
                                                },
                                                {
                                                  "type": "boolean"
                                                }
                                              ]
                                            },
                                            {
                                              "maxItems": 50,
                                              "type": "array",
                                              "items": {
                                                "anyOf": [
                                                  {
                                                    "type": "string",
                                                    "maxLength": 500
                                                  },
                                                  {
                                                    "type": "number"
                                                  },
                                                  {
                                                    "type": "boolean"
                                                  }
                                                ]
                                              }
                                            }
                                          ]
                                        }
                                      },
                                      "required": ["field", "op"],
                                      "additionalProperties": false
                                    },
                                    {
                                      "type": "object",
                                      "properties": {
                                        "event": {
                                          "type": "string",
                                          "pattern": "^[a-z][a-z0-9_]{0,63}$"
                                        }
                                      },
                                      "required": ["event"],
                                      "additionalProperties": false
                                    }
                                  ]
                                }
                              }
                            },
                            "required": ["any"],
                            "additionalProperties": false
                          }
                        ]
                      },
                      "transferRules": {
                        "maxItems": 10,
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "pattern": "^[a-z][a-z0-9_]{0,39}$"
                            },
                            "name": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 80
                            },
                            "when": {
                              "anyOf": [
                                {
                                  "type": "object",
                                  "properties": {
                                    "all": {
                                      "minItems": 1,
                                      "maxItems": 20,
                                      "type": "array",
                                      "items": {
                                        "anyOf": [
                                          {
                                            "type": "object",
                                            "properties": {
                                              "field": {
                                                "type": "string",
                                                "pattern": "^[a-z][a-z0-9_]{0,39}$"
                                              },
                                              "op": {
                                                "type": "string",
                                                "enum": [
                                                  "eq",
                                                  "neq",
                                                  "contains",
                                                  "not_contains",
                                                  "gt",
                                                  "gte",
                                                  "lt",
                                                  "lte",
                                                  "in",
                                                  "exists",
                                                  "not_exists"
                                                ]
                                              },
                                              "value": {
                                                "anyOf": [
                                                  {
                                                    "anyOf": [
                                                      {
                                                        "type": "string",
                                                        "maxLength": 500
                                                      },
                                                      {
                                                        "type": "number"
                                                      },
                                                      {
                                                        "type": "boolean"
                                                      }
                                                    ]
                                                  },
                                                  {
                                                    "maxItems": 50,
                                                    "type": "array",
                                                    "items": {
                                                      "anyOf": [
                                                        {
                                                          "type": "string",
                                                          "maxLength": 500
                                                        },
                                                        {
                                                          "type": "number"
                                                        },
                                                        {
                                                          "type": "boolean"
                                                        }
                                                      ]
                                                    }
                                                  }
                                                ]
                                              }
                                            },
                                            "required": ["field", "op"],
                                            "additionalProperties": false
                                          },
                                          {
                                            "type": "object",
                                            "properties": {
                                              "event": {
                                                "type": "string",
                                                "pattern": "^[a-z][a-z0-9_]{0,63}$"
                                              }
                                            },
                                            "required": ["event"],
                                            "additionalProperties": false
                                          }
                                        ]
                                      }
                                    }
                                  },
                                  "required": ["all"],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "any": {
                                      "minItems": 1,
                                      "maxItems": 20,
                                      "type": "array",
                                      "items": {
                                        "anyOf": [
                                          {
                                            "type": "object",
                                            "properties": {
                                              "field": {
                                                "type": "string",
                                                "pattern": "^[a-z][a-z0-9_]{0,39}$"
                                              },
                                              "op": {
                                                "type": "string",
                                                "enum": [
                                                  "eq",
                                                  "neq",
                                                  "contains",
                                                  "not_contains",
                                                  "gt",
                                                  "gte",
                                                  "lt",
                                                  "lte",
                                                  "in",
                                                  "exists",
                                                  "not_exists"
                                                ]
                                              },
                                              "value": {
                                                "anyOf": [
                                                  {
                                                    "anyOf": [
                                                      {
                                                        "type": "string",
                                                        "maxLength": 500
                                                      },
                                                      {
                                                        "type": "number"
                                                      },
                                                      {
                                                        "type": "boolean"
                                                      }
                                                    ]
                                                  },
                                                  {
                                                    "maxItems": 50,
                                                    "type": "array",
                                                    "items": {
                                                      "anyOf": [
                                                        {
                                                          "type": "string",
                                                          "maxLength": 500
                                                        },
                                                        {
                                                          "type": "number"
                                                        },
                                                        {
                                                          "type": "boolean"
                                                        }
                                                      ]
                                                    }
                                                  }
                                                ]
                                              }
                                            },
                                            "required": ["field", "op"],
                                            "additionalProperties": false
                                          },
                                          {
                                            "type": "object",
                                            "properties": {
                                              "event": {
                                                "type": "string",
                                                "pattern": "^[a-z][a-z0-9_]{0,63}$"
                                              }
                                            },
                                            "required": ["event"],
                                            "additionalProperties": false
                                          }
                                        ]
                                      }
                                    }
                                  },
                                  "required": ["any"],
                                  "additionalProperties": false
                                }
                              ]
                            },
                            "to": {
                              "type": "string",
                              "pattern": "^\\+[1-9]\\d{6,14}$"
                            },
                            "whisper": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 500
                            },
                            "handoffLine": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 200
                            },
                            "hours": {
                              "type": "object",
                              "properties": {
                                "windows": {
                                  "type": "object",
                                  "properties": {
                                    "sun": {
                                      "maxItems": 4,
                                      "type": "array",
                                      "items": {
                                        "type": "array",
                                        "prefixItems": [
                                          {
                                            "type": "string",
                                            "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                          },
                                          {
                                            "type": "string",
                                            "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                          }
                                        ]
                                      }
                                    },
                                    "mon": {
                                      "maxItems": 4,
                                      "type": "array",
                                      "items": {
                                        "type": "array",
                                        "prefixItems": [
                                          {
                                            "type": "string",
                                            "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                          },
                                          {
                                            "type": "string",
                                            "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                          }
                                        ]
                                      }
                                    },
                                    "tue": {
                                      "maxItems": 4,
                                      "type": "array",
                                      "items": {
                                        "type": "array",
                                        "prefixItems": [
                                          {
                                            "type": "string",
                                            "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                          },
                                          {
                                            "type": "string",
                                            "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                          }
                                        ]
                                      }
                                    },
                                    "wed": {
                                      "maxItems": 4,
                                      "type": "array",
                                      "items": {
                                        "type": "array",
                                        "prefixItems": [
                                          {
                                            "type": "string",
                                            "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                          },
                                          {
                                            "type": "string",
                                            "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                          }
                                        ]
                                      }
                                    },
                                    "thu": {
                                      "maxItems": 4,
                                      "type": "array",
                                      "items": {
                                        "type": "array",
                                        "prefixItems": [
                                          {
                                            "type": "string",
                                            "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                          },
                                          {
                                            "type": "string",
                                            "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                          }
                                        ]
                                      }
                                    },
                                    "fri": {
                                      "maxItems": 4,
                                      "type": "array",
                                      "items": {
                                        "type": "array",
                                        "prefixItems": [
                                          {
                                            "type": "string",
                                            "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                          },
                                          {
                                            "type": "string",
                                            "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                          }
                                        ]
                                      }
                                    },
                                    "sat": {
                                      "maxItems": 4,
                                      "type": "array",
                                      "items": {
                                        "type": "array",
                                        "prefixItems": [
                                          {
                                            "type": "string",
                                            "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                          },
                                          {
                                            "type": "string",
                                            "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                          }
                                        ]
                                      }
                                    }
                                  },
                                  "additionalProperties": false
                                },
                                "timezone": {
                                  "type": "string",
                                  "minLength": 1,
                                  "maxLength": 64
                                }
                              },
                              "required": ["windows", "timezone"],
                              "additionalProperties": false
                            },
                            "fallback": {
                              "default": "callback",
                              "type": "string",
                              "enum": ["callback", "end"]
                            }
                          },
                          "required": ["id", "name", "when", "to", "whisper", "handoffLine"],
                          "additionalProperties": false
                        }
                      }
                    },
                    "additionalProperties": false
                  }
                },
                "required": ["orgId"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 128
                    },
                    "orgId": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "purpose": {
                      "type": "string",
                      "enum": ["marketing", "lead_followup", "service"]
                    },
                    "status": {
                      "type": "string",
                      "enum": ["draft", "launching", "running", "paused", "completed", "archived"]
                    },
                    "alwaysOn": {
                      "type": "boolean"
                    },
                    "priority": {
                      "type": "number"
                    },
                    "inboxId": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 128
                    },
                    "settings": {
                      "type": "object",
                      "properties": {
                        "brief": {
                          "default": "",
                          "type": "string",
                          "maxLength": 4000
                        },
                        "purposeLine": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 200
                        },
                        "addressOrFreephone": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 200
                        },
                        "schedule": {
                          "default": {},
                          "type": "object",
                          "properties": {
                            "startAt": {
                              "type": "string",
                              "format": "date-time",
                              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                            },
                            "endAt": {
                              "type": "string",
                              "format": "date-time",
                              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                            },
                            "windows": {
                              "type": "object",
                              "properties": {
                                "sun": {
                                  "maxItems": 4,
                                  "type": "array",
                                  "items": {
                                    "type": "array",
                                    "prefixItems": [
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      },
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      }
                                    ]
                                  }
                                },
                                "mon": {
                                  "maxItems": 4,
                                  "type": "array",
                                  "items": {
                                    "type": "array",
                                    "prefixItems": [
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      },
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      }
                                    ]
                                  }
                                },
                                "tue": {
                                  "maxItems": 4,
                                  "type": "array",
                                  "items": {
                                    "type": "array",
                                    "prefixItems": [
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      },
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      }
                                    ]
                                  }
                                },
                                "wed": {
                                  "maxItems": 4,
                                  "type": "array",
                                  "items": {
                                    "type": "array",
                                    "prefixItems": [
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      },
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      }
                                    ]
                                  }
                                },
                                "thu": {
                                  "maxItems": 4,
                                  "type": "array",
                                  "items": {
                                    "type": "array",
                                    "prefixItems": [
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      },
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      }
                                    ]
                                  }
                                },
                                "fri": {
                                  "maxItems": 4,
                                  "type": "array",
                                  "items": {
                                    "type": "array",
                                    "prefixItems": [
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      },
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      }
                                    ]
                                  }
                                },
                                "sat": {
                                  "maxItems": 4,
                                  "type": "array",
                                  "items": {
                                    "type": "array",
                                    "prefixItems": [
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      },
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      }
                                    ]
                                  }
                                }
                              },
                              "additionalProperties": false
                            }
                          },
                          "additionalProperties": false
                        },
                        "pacing": {
                          "default": {
                            "maxConcurrent": 2,
                            "maxPerHour": 60,
                            "maxNewNumbersPerHour": 30
                          },
                          "type": "object",
                          "properties": {
                            "maxConcurrent": {
                              "default": 2,
                              "type": "integer",
                              "minimum": 1,
                              "maximum": 50
                            },
                            "maxPerHour": {
                              "default": 60,
                              "type": "integer",
                              "minimum": 1,
                              "maximum": 5000
                            },
                            "maxNewNumbersPerHour": {
                              "default": 30,
                              "type": "integer",
                              "minimum": 1,
                              "maximum": 1000
                            }
                          },
                          "required": ["maxConcurrent", "maxPerHour", "maxNewNumbersPerHour"],
                          "additionalProperties": false
                        },
                        "retry": {
                          "default": {
                            "maxAttempts": 3,
                            "retryOn": ["no_answer", "busy", "voicemail"],
                            "gapMinutes": 240
                          },
                          "type": "object",
                          "properties": {
                            "maxAttempts": {
                              "default": 3,
                              "type": "integer",
                              "minimum": 1,
                              "maximum": 3
                            },
                            "retryOn": {
                              "default": ["no_answer", "busy", "voicemail"],
                              "maxItems": 10,
                              "type": "array",
                              "items": {
                                "type": "string",
                                "enum": [
                                  "human",
                                  "voicemail",
                                  "fax",
                                  "no_answer",
                                  "busy",
                                  "failed",
                                  "canceled",
                                  "transferred",
                                  "opted_out",
                                  "abandoned"
                                ]
                              }
                            },
                            "gapMinutes": {
                              "default": 240,
                              "type": "integer",
                              "minimum": 240,
                              "maximum": 10080
                            }
                          },
                          "required": ["maxAttempts", "retryOn", "gapMinutes"],
                          "additionalProperties": false
                        },
                        "dataFields": {
                          "default": [],
                          "maxItems": 20,
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string",
                                "pattern": "^[a-z][a-z0-9_]{0,39}$"
                              },
                              "label": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 80
                              },
                              "type": {
                                "type": "string",
                                "enum": ["boolean", "string", "integer", "number"]
                              },
                              "description": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 500
                              },
                              "enum": {
                                "minItems": 1,
                                "maxItems": 20,
                                "type": "array",
                                "items": {
                                  "type": "string",
                                  "maxLength": 80
                                }
                              }
                            },
                            "required": ["id", "label", "type", "description"],
                            "additionalProperties": false
                          }
                        },
                        "successCriterion": {
                          "anyOf": [
                            {
                              "type": "object",
                              "properties": {
                                "all": {
                                  "minItems": 1,
                                  "maxItems": 20,
                                  "type": "array",
                                  "items": {
                                    "anyOf": [
                                      {
                                        "type": "object",
                                        "properties": {
                                          "field": {
                                            "type": "string",
                                            "pattern": "^[a-z][a-z0-9_]{0,39}$"
                                          },
                                          "op": {
                                            "type": "string",
                                            "enum": [
                                              "eq",
                                              "neq",
                                              "contains",
                                              "not_contains",
                                              "gt",
                                              "gte",
                                              "lt",
                                              "lte",
                                              "in",
                                              "exists",
                                              "not_exists"
                                            ]
                                          },
                                          "value": {
                                            "anyOf": [
                                              {
                                                "anyOf": [
                                                  {
                                                    "type": "string",
                                                    "maxLength": 500
                                                  },
                                                  {
                                                    "type": "number"
                                                  },
                                                  {
                                                    "type": "boolean"
                                                  }
                                                ]
                                              },
                                              {
                                                "maxItems": 50,
                                                "type": "array",
                                                "items": {
                                                  "anyOf": [
                                                    {
                                                      "type": "string",
                                                      "maxLength": 500
                                                    },
                                                    {
                                                      "type": "number"
                                                    },
                                                    {
                                                      "type": "boolean"
                                                    }
                                                  ]
                                                }
                                              }
                                            ]
                                          }
                                        },
                                        "required": ["field", "op"],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "event": {
                                            "type": "string",
                                            "pattern": "^[a-z][a-z0-9_]{0,63}$"
                                          }
                                        },
                                        "required": ["event"],
                                        "additionalProperties": false
                                      }
                                    ]
                                  }
                                }
                              },
                              "required": ["all"],
                              "additionalProperties": false
                            },
                            {
                              "type": "object",
                              "properties": {
                                "any": {
                                  "minItems": 1,
                                  "maxItems": 20,
                                  "type": "array",
                                  "items": {
                                    "anyOf": [
                                      {
                                        "type": "object",
                                        "properties": {
                                          "field": {
                                            "type": "string",
                                            "pattern": "^[a-z][a-z0-9_]{0,39}$"
                                          },
                                          "op": {
                                            "type": "string",
                                            "enum": [
                                              "eq",
                                              "neq",
                                              "contains",
                                              "not_contains",
                                              "gt",
                                              "gte",
                                              "lt",
                                              "lte",
                                              "in",
                                              "exists",
                                              "not_exists"
                                            ]
                                          },
                                          "value": {
                                            "anyOf": [
                                              {
                                                "anyOf": [
                                                  {
                                                    "type": "string",
                                                    "maxLength": 500
                                                  },
                                                  {
                                                    "type": "number"
                                                  },
                                                  {
                                                    "type": "boolean"
                                                  }
                                                ]
                                              },
                                              {
                                                "maxItems": 50,
                                                "type": "array",
                                                "items": {
                                                  "anyOf": [
                                                    {
                                                      "type": "string",
                                                      "maxLength": 500
                                                    },
                                                    {
                                                      "type": "number"
                                                    },
                                                    {
                                                      "type": "boolean"
                                                    }
                                                  ]
                                                }
                                              }
                                            ]
                                          }
                                        },
                                        "required": ["field", "op"],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "event": {
                                            "type": "string",
                                            "pattern": "^[a-z][a-z0-9_]{0,63}$"
                                          }
                                        },
                                        "required": ["event"],
                                        "additionalProperties": false
                                      }
                                    ]
                                  }
                                }
                              },
                              "required": ["any"],
                              "additionalProperties": false
                            }
                          ]
                        },
                        "transferRules": {
                          "default": [],
                          "maxItems": 10,
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string",
                                "pattern": "^[a-z][a-z0-9_]{0,39}$"
                              },
                              "name": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 80
                              },
                              "when": {
                                "anyOf": [
                                  {
                                    "type": "object",
                                    "properties": {
                                      "all": {
                                        "minItems": 1,
                                        "maxItems": 20,
                                        "type": "array",
                                        "items": {
                                          "anyOf": [
                                            {
                                              "type": "object",
                                              "properties": {
                                                "field": {
                                                  "type": "string",
                                                  "pattern": "^[a-z][a-z0-9_]{0,39}$"
                                                },
                                                "op": {
                                                  "type": "string",
                                                  "enum": [
                                                    "eq",
                                                    "neq",
                                                    "contains",
                                                    "not_contains",
                                                    "gt",
                                                    "gte",
                                                    "lt",
                                                    "lte",
                                                    "in",
                                                    "exists",
                                                    "not_exists"
                                                  ]
                                                },
                                                "value": {
                                                  "anyOf": [
                                                    {
                                                      "anyOf": [
                                                        {
                                                          "type": "string",
                                                          "maxLength": 500
                                                        },
                                                        {
                                                          "type": "number"
                                                        },
                                                        {
                                                          "type": "boolean"
                                                        }
                                                      ]
                                                    },
                                                    {
                                                      "maxItems": 50,
                                                      "type": "array",
                                                      "items": {
                                                        "anyOf": [
                                                          {
                                                            "type": "string",
                                                            "maxLength": 500
                                                          },
                                                          {
                                                            "type": "number"
                                                          },
                                                          {
                                                            "type": "boolean"
                                                          }
                                                        ]
                                                      }
                                                    }
                                                  ]
                                                }
                                              },
                                              "required": ["field", "op"],
                                              "additionalProperties": false
                                            },
                                            {
                                              "type": "object",
                                              "properties": {
                                                "event": {
                                                  "type": "string",
                                                  "pattern": "^[a-z][a-z0-9_]{0,63}$"
                                                }
                                              },
                                              "required": ["event"],
                                              "additionalProperties": false
                                            }
                                          ]
                                        }
                                      }
                                    },
                                    "required": ["all"],
                                    "additionalProperties": false
                                  },
                                  {
                                    "type": "object",
                                    "properties": {
                                      "any": {
                                        "minItems": 1,
                                        "maxItems": 20,
                                        "type": "array",
                                        "items": {
                                          "anyOf": [
                                            {
                                              "type": "object",
                                              "properties": {
                                                "field": {
                                                  "type": "string",
                                                  "pattern": "^[a-z][a-z0-9_]{0,39}$"
                                                },
                                                "op": {
                                                  "type": "string",
                                                  "enum": [
                                                    "eq",
                                                    "neq",
                                                    "contains",
                                                    "not_contains",
                                                    "gt",
                                                    "gte",
                                                    "lt",
                                                    "lte",
                                                    "in",
                                                    "exists",
                                                    "not_exists"
                                                  ]
                                                },
                                                "value": {
                                                  "anyOf": [
                                                    {
                                                      "anyOf": [
                                                        {
                                                          "type": "string",
                                                          "maxLength": 500
                                                        },
                                                        {
                                                          "type": "number"
                                                        },
                                                        {
                                                          "type": "boolean"
                                                        }
                                                      ]
                                                    },
                                                    {
                                                      "maxItems": 50,
                                                      "type": "array",
                                                      "items": {
                                                        "anyOf": [
                                                          {
                                                            "type": "string",
                                                            "maxLength": 500
                                                          },
                                                          {
                                                            "type": "number"
                                                          },
                                                          {
                                                            "type": "boolean"
                                                          }
                                                        ]
                                                      }
                                                    }
                                                  ]
                                                }
                                              },
                                              "required": ["field", "op"],
                                              "additionalProperties": false
                                            },
                                            {
                                              "type": "object",
                                              "properties": {
                                                "event": {
                                                  "type": "string",
                                                  "pattern": "^[a-z][a-z0-9_]{0,63}$"
                                                }
                                              },
                                              "required": ["event"],
                                              "additionalProperties": false
                                            }
                                          ]
                                        }
                                      }
                                    },
                                    "required": ["any"],
                                    "additionalProperties": false
                                  }
                                ]
                              },
                              "to": {
                                "type": "string",
                                "pattern": "^\\+[1-9]\\d{6,14}$"
                              },
                              "whisper": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 500
                              },
                              "handoffLine": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 200
                              },
                              "hours": {
                                "type": "object",
                                "properties": {
                                  "windows": {
                                    "type": "object",
                                    "properties": {
                                      "sun": {
                                        "maxItems": 4,
                                        "type": "array",
                                        "items": {
                                          "type": "array",
                                          "prefixItems": [
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            },
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            }
                                          ]
                                        }
                                      },
                                      "mon": {
                                        "maxItems": 4,
                                        "type": "array",
                                        "items": {
                                          "type": "array",
                                          "prefixItems": [
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            },
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            }
                                          ]
                                        }
                                      },
                                      "tue": {
                                        "maxItems": 4,
                                        "type": "array",
                                        "items": {
                                          "type": "array",
                                          "prefixItems": [
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            },
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            }
                                          ]
                                        }
                                      },
                                      "wed": {
                                        "maxItems": 4,
                                        "type": "array",
                                        "items": {
                                          "type": "array",
                                          "prefixItems": [
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            },
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            }
                                          ]
                                        }
                                      },
                                      "thu": {
                                        "maxItems": 4,
                                        "type": "array",
                                        "items": {
                                          "type": "array",
                                          "prefixItems": [
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            },
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            }
                                          ]
                                        }
                                      },
                                      "fri": {
                                        "maxItems": 4,
                                        "type": "array",
                                        "items": {
                                          "type": "array",
                                          "prefixItems": [
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            },
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            }
                                          ]
                                        }
                                      },
                                      "sat": {
                                        "maxItems": 4,
                                        "type": "array",
                                        "items": {
                                          "type": "array",
                                          "prefixItems": [
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            },
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            }
                                          ]
                                        }
                                      }
                                    },
                                    "additionalProperties": false
                                  },
                                  "timezone": {
                                    "type": "string",
                                    "minLength": 1,
                                    "maxLength": 64
                                  }
                                },
                                "required": ["windows", "timezone"],
                                "additionalProperties": false
                              },
                              "fallback": {
                                "default": "callback",
                                "type": "string",
                                "enum": ["callback", "end"]
                              }
                            },
                            "required": [
                              "id",
                              "name",
                              "when",
                              "to",
                              "whisper",
                              "handoffLine",
                              "fallback"
                            ],
                            "additionalProperties": false
                          }
                        }
                      },
                      "required": [
                        "brief",
                        "purposeLine",
                        "schedule",
                        "pacing",
                        "retry",
                        "dataFields",
                        "transferRules"
                      ],
                      "additionalProperties": false
                    },
                    "requiredVariables": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "settingsConfirmedBy": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "pausedReason": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "createdBy": {
                      "type": "string"
                    },
                    "launchedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "completedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "createdAt": {
                      "type": "string"
                    },
                    "updatedAt": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "id",
                    "orgId",
                    "name",
                    "purpose",
                    "status",
                    "alwaysOn",
                    "priority",
                    "inboxId",
                    "settings",
                    "requiredVariables",
                    "settingsConfirmedBy",
                    "pausedReason",
                    "createdBy",
                    "launchedAt",
                    "completedAt",
                    "createdAt",
                    "updatedAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/outbound/campaigns/{id}": {
      "get": {
        "operationId": "outbound-campaigns-get",
        "summary": "Get an outbound campaign and request counts",
        "tags": ["Outbound"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 128
            },
            "required": true
          },
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 128
                    },
                    "orgId": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "purpose": {
                      "type": "string",
                      "enum": ["marketing", "lead_followup", "service"]
                    },
                    "status": {
                      "type": "string",
                      "enum": ["draft", "launching", "running", "paused", "completed", "archived"]
                    },
                    "alwaysOn": {
                      "type": "boolean"
                    },
                    "priority": {
                      "type": "number"
                    },
                    "inboxId": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 128
                    },
                    "settings": {
                      "type": "object",
                      "properties": {
                        "brief": {
                          "default": "",
                          "type": "string",
                          "maxLength": 4000
                        },
                        "purposeLine": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 200
                        },
                        "addressOrFreephone": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 200
                        },
                        "schedule": {
                          "default": {},
                          "type": "object",
                          "properties": {
                            "startAt": {
                              "type": "string",
                              "format": "date-time",
                              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                            },
                            "endAt": {
                              "type": "string",
                              "format": "date-time",
                              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                            },
                            "windows": {
                              "type": "object",
                              "properties": {
                                "sun": {
                                  "maxItems": 4,
                                  "type": "array",
                                  "items": {
                                    "type": "array",
                                    "prefixItems": [
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      },
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      }
                                    ]
                                  }
                                },
                                "mon": {
                                  "maxItems": 4,
                                  "type": "array",
                                  "items": {
                                    "type": "array",
                                    "prefixItems": [
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      },
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      }
                                    ]
                                  }
                                },
                                "tue": {
                                  "maxItems": 4,
                                  "type": "array",
                                  "items": {
                                    "type": "array",
                                    "prefixItems": [
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      },
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      }
                                    ]
                                  }
                                },
                                "wed": {
                                  "maxItems": 4,
                                  "type": "array",
                                  "items": {
                                    "type": "array",
                                    "prefixItems": [
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      },
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      }
                                    ]
                                  }
                                },
                                "thu": {
                                  "maxItems": 4,
                                  "type": "array",
                                  "items": {
                                    "type": "array",
                                    "prefixItems": [
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      },
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      }
                                    ]
                                  }
                                },
                                "fri": {
                                  "maxItems": 4,
                                  "type": "array",
                                  "items": {
                                    "type": "array",
                                    "prefixItems": [
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      },
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      }
                                    ]
                                  }
                                },
                                "sat": {
                                  "maxItems": 4,
                                  "type": "array",
                                  "items": {
                                    "type": "array",
                                    "prefixItems": [
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      },
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      }
                                    ]
                                  }
                                }
                              },
                              "additionalProperties": false
                            }
                          },
                          "additionalProperties": false
                        },
                        "pacing": {
                          "default": {
                            "maxConcurrent": 2,
                            "maxPerHour": 60,
                            "maxNewNumbersPerHour": 30
                          },
                          "type": "object",
                          "properties": {
                            "maxConcurrent": {
                              "default": 2,
                              "type": "integer",
                              "minimum": 1,
                              "maximum": 50
                            },
                            "maxPerHour": {
                              "default": 60,
                              "type": "integer",
                              "minimum": 1,
                              "maximum": 5000
                            },
                            "maxNewNumbersPerHour": {
                              "default": 30,
                              "type": "integer",
                              "minimum": 1,
                              "maximum": 1000
                            }
                          },
                          "required": ["maxConcurrent", "maxPerHour", "maxNewNumbersPerHour"],
                          "additionalProperties": false
                        },
                        "retry": {
                          "default": {
                            "maxAttempts": 3,
                            "retryOn": ["no_answer", "busy", "voicemail"],
                            "gapMinutes": 240
                          },
                          "type": "object",
                          "properties": {
                            "maxAttempts": {
                              "default": 3,
                              "type": "integer",
                              "minimum": 1,
                              "maximum": 3
                            },
                            "retryOn": {
                              "default": ["no_answer", "busy", "voicemail"],
                              "maxItems": 10,
                              "type": "array",
                              "items": {
                                "type": "string",
                                "enum": [
                                  "human",
                                  "voicemail",
                                  "fax",
                                  "no_answer",
                                  "busy",
                                  "failed",
                                  "canceled",
                                  "transferred",
                                  "opted_out",
                                  "abandoned"
                                ]
                              }
                            },
                            "gapMinutes": {
                              "default": 240,
                              "type": "integer",
                              "minimum": 240,
                              "maximum": 10080
                            }
                          },
                          "required": ["maxAttempts", "retryOn", "gapMinutes"],
                          "additionalProperties": false
                        },
                        "dataFields": {
                          "default": [],
                          "maxItems": 20,
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string",
                                "pattern": "^[a-z][a-z0-9_]{0,39}$"
                              },
                              "label": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 80
                              },
                              "type": {
                                "type": "string",
                                "enum": ["boolean", "string", "integer", "number"]
                              },
                              "description": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 500
                              },
                              "enum": {
                                "minItems": 1,
                                "maxItems": 20,
                                "type": "array",
                                "items": {
                                  "type": "string",
                                  "maxLength": 80
                                }
                              }
                            },
                            "required": ["id", "label", "type", "description"],
                            "additionalProperties": false
                          }
                        },
                        "successCriterion": {
                          "anyOf": [
                            {
                              "type": "object",
                              "properties": {
                                "all": {
                                  "minItems": 1,
                                  "maxItems": 20,
                                  "type": "array",
                                  "items": {
                                    "anyOf": [
                                      {
                                        "type": "object",
                                        "properties": {
                                          "field": {
                                            "type": "string",
                                            "pattern": "^[a-z][a-z0-9_]{0,39}$"
                                          },
                                          "op": {
                                            "type": "string",
                                            "enum": [
                                              "eq",
                                              "neq",
                                              "contains",
                                              "not_contains",
                                              "gt",
                                              "gte",
                                              "lt",
                                              "lte",
                                              "in",
                                              "exists",
                                              "not_exists"
                                            ]
                                          },
                                          "value": {
                                            "anyOf": [
                                              {
                                                "anyOf": [
                                                  {
                                                    "type": "string",
                                                    "maxLength": 500
                                                  },
                                                  {
                                                    "type": "number"
                                                  },
                                                  {
                                                    "type": "boolean"
                                                  }
                                                ]
                                              },
                                              {
                                                "maxItems": 50,
                                                "type": "array",
                                                "items": {
                                                  "anyOf": [
                                                    {
                                                      "type": "string",
                                                      "maxLength": 500
                                                    },
                                                    {
                                                      "type": "number"
                                                    },
                                                    {
                                                      "type": "boolean"
                                                    }
                                                  ]
                                                }
                                              }
                                            ]
                                          }
                                        },
                                        "required": ["field", "op"],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "event": {
                                            "type": "string",
                                            "pattern": "^[a-z][a-z0-9_]{0,63}$"
                                          }
                                        },
                                        "required": ["event"],
                                        "additionalProperties": false
                                      }
                                    ]
                                  }
                                }
                              },
                              "required": ["all"],
                              "additionalProperties": false
                            },
                            {
                              "type": "object",
                              "properties": {
                                "any": {
                                  "minItems": 1,
                                  "maxItems": 20,
                                  "type": "array",
                                  "items": {
                                    "anyOf": [
                                      {
                                        "type": "object",
                                        "properties": {
                                          "field": {
                                            "type": "string",
                                            "pattern": "^[a-z][a-z0-9_]{0,39}$"
                                          },
                                          "op": {
                                            "type": "string",
                                            "enum": [
                                              "eq",
                                              "neq",
                                              "contains",
                                              "not_contains",
                                              "gt",
                                              "gte",
                                              "lt",
                                              "lte",
                                              "in",
                                              "exists",
                                              "not_exists"
                                            ]
                                          },
                                          "value": {
                                            "anyOf": [
                                              {
                                                "anyOf": [
                                                  {
                                                    "type": "string",
                                                    "maxLength": 500
                                                  },
                                                  {
                                                    "type": "number"
                                                  },
                                                  {
                                                    "type": "boolean"
                                                  }
                                                ]
                                              },
                                              {
                                                "maxItems": 50,
                                                "type": "array",
                                                "items": {
                                                  "anyOf": [
                                                    {
                                                      "type": "string",
                                                      "maxLength": 500
                                                    },
                                                    {
                                                      "type": "number"
                                                    },
                                                    {
                                                      "type": "boolean"
                                                    }
                                                  ]
                                                }
                                              }
                                            ]
                                          }
                                        },
                                        "required": ["field", "op"],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "event": {
                                            "type": "string",
                                            "pattern": "^[a-z][a-z0-9_]{0,63}$"
                                          }
                                        },
                                        "required": ["event"],
                                        "additionalProperties": false
                                      }
                                    ]
                                  }
                                }
                              },
                              "required": ["any"],
                              "additionalProperties": false
                            }
                          ]
                        },
                        "transferRules": {
                          "default": [],
                          "maxItems": 10,
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string",
                                "pattern": "^[a-z][a-z0-9_]{0,39}$"
                              },
                              "name": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 80
                              },
                              "when": {
                                "anyOf": [
                                  {
                                    "type": "object",
                                    "properties": {
                                      "all": {
                                        "minItems": 1,
                                        "maxItems": 20,
                                        "type": "array",
                                        "items": {
                                          "anyOf": [
                                            {
                                              "type": "object",
                                              "properties": {
                                                "field": {
                                                  "type": "string",
                                                  "pattern": "^[a-z][a-z0-9_]{0,39}$"
                                                },
                                                "op": {
                                                  "type": "string",
                                                  "enum": [
                                                    "eq",
                                                    "neq",
                                                    "contains",
                                                    "not_contains",
                                                    "gt",
                                                    "gte",
                                                    "lt",
                                                    "lte",
                                                    "in",
                                                    "exists",
                                                    "not_exists"
                                                  ]
                                                },
                                                "value": {
                                                  "anyOf": [
                                                    {
                                                      "anyOf": [
                                                        {
                                                          "type": "string",
                                                          "maxLength": 500
                                                        },
                                                        {
                                                          "type": "number"
                                                        },
                                                        {
                                                          "type": "boolean"
                                                        }
                                                      ]
                                                    },
                                                    {
                                                      "maxItems": 50,
                                                      "type": "array",
                                                      "items": {
                                                        "anyOf": [
                                                          {
                                                            "type": "string",
                                                            "maxLength": 500
                                                          },
                                                          {
                                                            "type": "number"
                                                          },
                                                          {
                                                            "type": "boolean"
                                                          }
                                                        ]
                                                      }
                                                    }
                                                  ]
                                                }
                                              },
                                              "required": ["field", "op"],
                                              "additionalProperties": false
                                            },
                                            {
                                              "type": "object",
                                              "properties": {
                                                "event": {
                                                  "type": "string",
                                                  "pattern": "^[a-z][a-z0-9_]{0,63}$"
                                                }
                                              },
                                              "required": ["event"],
                                              "additionalProperties": false
                                            }
                                          ]
                                        }
                                      }
                                    },
                                    "required": ["all"],
                                    "additionalProperties": false
                                  },
                                  {
                                    "type": "object",
                                    "properties": {
                                      "any": {
                                        "minItems": 1,
                                        "maxItems": 20,
                                        "type": "array",
                                        "items": {
                                          "anyOf": [
                                            {
                                              "type": "object",
                                              "properties": {
                                                "field": {
                                                  "type": "string",
                                                  "pattern": "^[a-z][a-z0-9_]{0,39}$"
                                                },
                                                "op": {
                                                  "type": "string",
                                                  "enum": [
                                                    "eq",
                                                    "neq",
                                                    "contains",
                                                    "not_contains",
                                                    "gt",
                                                    "gte",
                                                    "lt",
                                                    "lte",
                                                    "in",
                                                    "exists",
                                                    "not_exists"
                                                  ]
                                                },
                                                "value": {
                                                  "anyOf": [
                                                    {
                                                      "anyOf": [
                                                        {
                                                          "type": "string",
                                                          "maxLength": 500
                                                        },
                                                        {
                                                          "type": "number"
                                                        },
                                                        {
                                                          "type": "boolean"
                                                        }
                                                      ]
                                                    },
                                                    {
                                                      "maxItems": 50,
                                                      "type": "array",
                                                      "items": {
                                                        "anyOf": [
                                                          {
                                                            "type": "string",
                                                            "maxLength": 500
                                                          },
                                                          {
                                                            "type": "number"
                                                          },
                                                          {
                                                            "type": "boolean"
                                                          }
                                                        ]
                                                      }
                                                    }
                                                  ]
                                                }
                                              },
                                              "required": ["field", "op"],
                                              "additionalProperties": false
                                            },
                                            {
                                              "type": "object",
                                              "properties": {
                                                "event": {
                                                  "type": "string",
                                                  "pattern": "^[a-z][a-z0-9_]{0,63}$"
                                                }
                                              },
                                              "required": ["event"],
                                              "additionalProperties": false
                                            }
                                          ]
                                        }
                                      }
                                    },
                                    "required": ["any"],
                                    "additionalProperties": false
                                  }
                                ]
                              },
                              "to": {
                                "type": "string",
                                "pattern": "^\\+[1-9]\\d{6,14}$"
                              },
                              "whisper": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 500
                              },
                              "handoffLine": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 200
                              },
                              "hours": {
                                "type": "object",
                                "properties": {
                                  "windows": {
                                    "type": "object",
                                    "properties": {
                                      "sun": {
                                        "maxItems": 4,
                                        "type": "array",
                                        "items": {
                                          "type": "array",
                                          "prefixItems": [
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            },
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            }
                                          ]
                                        }
                                      },
                                      "mon": {
                                        "maxItems": 4,
                                        "type": "array",
                                        "items": {
                                          "type": "array",
                                          "prefixItems": [
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            },
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            }
                                          ]
                                        }
                                      },
                                      "tue": {
                                        "maxItems": 4,
                                        "type": "array",
                                        "items": {
                                          "type": "array",
                                          "prefixItems": [
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            },
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            }
                                          ]
                                        }
                                      },
                                      "wed": {
                                        "maxItems": 4,
                                        "type": "array",
                                        "items": {
                                          "type": "array",
                                          "prefixItems": [
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            },
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            }
                                          ]
                                        }
                                      },
                                      "thu": {
                                        "maxItems": 4,
                                        "type": "array",
                                        "items": {
                                          "type": "array",
                                          "prefixItems": [
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            },
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            }
                                          ]
                                        }
                                      },
                                      "fri": {
                                        "maxItems": 4,
                                        "type": "array",
                                        "items": {
                                          "type": "array",
                                          "prefixItems": [
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            },
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            }
                                          ]
                                        }
                                      },
                                      "sat": {
                                        "maxItems": 4,
                                        "type": "array",
                                        "items": {
                                          "type": "array",
                                          "prefixItems": [
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            },
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            }
                                          ]
                                        }
                                      }
                                    },
                                    "additionalProperties": false
                                  },
                                  "timezone": {
                                    "type": "string",
                                    "minLength": 1,
                                    "maxLength": 64
                                  }
                                },
                                "required": ["windows", "timezone"],
                                "additionalProperties": false
                              },
                              "fallback": {
                                "default": "callback",
                                "type": "string",
                                "enum": ["callback", "end"]
                              }
                            },
                            "required": [
                              "id",
                              "name",
                              "when",
                              "to",
                              "whisper",
                              "handoffLine",
                              "fallback"
                            ],
                            "additionalProperties": false
                          }
                        }
                      },
                      "required": [
                        "brief",
                        "purposeLine",
                        "schedule",
                        "pacing",
                        "retry",
                        "dataFields",
                        "transferRules"
                      ],
                      "additionalProperties": false
                    },
                    "requiredVariables": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "settingsConfirmedBy": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "pausedReason": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "createdBy": {
                      "type": "string"
                    },
                    "launchedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "completedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "createdAt": {
                      "type": "string"
                    },
                    "updatedAt": {
                      "type": "string"
                    },
                    "variants": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 128
                          },
                          "campaignId": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 128
                          },
                          "orgId": {
                            "type": "string"
                          },
                          "key": {
                            "type": "string",
                            "enum": ["A", "B", "C"]
                          },
                          "name": {
                            "type": "string"
                          },
                          "weight": {
                            "type": "number"
                          },
                          "baseAgentId": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 128
                          },
                          "overrides": {
                            "type": "object",
                            "properties": {
                              "greeting": {
                                "type": "string",
                                "maxLength": 500
                              },
                              "promptAppend": {
                                "type": "string",
                                "maxLength": 4000
                              },
                              "voiceId": {
                                "type": "string",
                                "maxLength": 100
                              }
                            },
                            "additionalProperties": false
                          },
                          "elevenLabsAgentId": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "elevenLabsWorkspace": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": ["platform", "byok"]
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "snapshotHash": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "status": {
                            "type": "string",
                            "enum": ["draft", "active", "stopped", "retired"]
                          },
                          "retiredAt": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "createdAt": {
                            "type": "string"
                          },
                          "updatedAt": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "id",
                          "campaignId",
                          "orgId",
                          "key",
                          "name",
                          "weight",
                          "baseAgentId",
                          "overrides",
                          "elevenLabsAgentId",
                          "elevenLabsWorkspace",
                          "snapshotHash",
                          "status",
                          "retiredAt",
                          "createdAt",
                          "updatedAt"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "counts": {
                      "type": "object",
                      "propertyNames": {
                        "type": "string",
                        "enum": [
                          "queued",
                          "dialing",
                          "in_call",
                          "completed",
                          "skipped",
                          "canceled",
                          "exhausted",
                          "failed"
                        ]
                      },
                      "additionalProperties": {
                        "type": "number"
                      }
                    }
                  },
                  "required": [
                    "id",
                    "orgId",
                    "name",
                    "purpose",
                    "status",
                    "alwaysOn",
                    "priority",
                    "inboxId",
                    "settings",
                    "requiredVariables",
                    "settingsConfirmedBy",
                    "pausedReason",
                    "createdBy",
                    "launchedAt",
                    "completedAt",
                    "createdAt",
                    "updatedAt",
                    "variants",
                    "counts"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/outbound/campaigns/{id}/launch": {
      "post": {
        "operationId": "outbound-campaigns-launch",
        "summary": "Validate and launch an outbound campaign",
        "tags": ["Outbound"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 128
            },
            "required": true
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "confirmScheduleAndRetry": {
                    "type": "boolean",
                    "const": true
                  }
                },
                "required": ["orgId", "confirmScheduleAndRetry"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 128
                    },
                    "orgId": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "purpose": {
                      "type": "string",
                      "enum": ["marketing", "lead_followup", "service"]
                    },
                    "status": {
                      "type": "string",
                      "enum": ["draft", "launching", "running", "paused", "completed", "archived"]
                    },
                    "alwaysOn": {
                      "type": "boolean"
                    },
                    "priority": {
                      "type": "number"
                    },
                    "inboxId": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 128
                    },
                    "settings": {
                      "type": "object",
                      "properties": {
                        "brief": {
                          "default": "",
                          "type": "string",
                          "maxLength": 4000
                        },
                        "purposeLine": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 200
                        },
                        "addressOrFreephone": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 200
                        },
                        "schedule": {
                          "default": {},
                          "type": "object",
                          "properties": {
                            "startAt": {
                              "type": "string",
                              "format": "date-time",
                              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                            },
                            "endAt": {
                              "type": "string",
                              "format": "date-time",
                              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                            },
                            "windows": {
                              "type": "object",
                              "properties": {
                                "sun": {
                                  "maxItems": 4,
                                  "type": "array",
                                  "items": {
                                    "type": "array",
                                    "prefixItems": [
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      },
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      }
                                    ]
                                  }
                                },
                                "mon": {
                                  "maxItems": 4,
                                  "type": "array",
                                  "items": {
                                    "type": "array",
                                    "prefixItems": [
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      },
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      }
                                    ]
                                  }
                                },
                                "tue": {
                                  "maxItems": 4,
                                  "type": "array",
                                  "items": {
                                    "type": "array",
                                    "prefixItems": [
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      },
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      }
                                    ]
                                  }
                                },
                                "wed": {
                                  "maxItems": 4,
                                  "type": "array",
                                  "items": {
                                    "type": "array",
                                    "prefixItems": [
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      },
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      }
                                    ]
                                  }
                                },
                                "thu": {
                                  "maxItems": 4,
                                  "type": "array",
                                  "items": {
                                    "type": "array",
                                    "prefixItems": [
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      },
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      }
                                    ]
                                  }
                                },
                                "fri": {
                                  "maxItems": 4,
                                  "type": "array",
                                  "items": {
                                    "type": "array",
                                    "prefixItems": [
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      },
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      }
                                    ]
                                  }
                                },
                                "sat": {
                                  "maxItems": 4,
                                  "type": "array",
                                  "items": {
                                    "type": "array",
                                    "prefixItems": [
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      },
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      }
                                    ]
                                  }
                                }
                              },
                              "additionalProperties": false
                            }
                          },
                          "additionalProperties": false
                        },
                        "pacing": {
                          "default": {
                            "maxConcurrent": 2,
                            "maxPerHour": 60,
                            "maxNewNumbersPerHour": 30
                          },
                          "type": "object",
                          "properties": {
                            "maxConcurrent": {
                              "default": 2,
                              "type": "integer",
                              "minimum": 1,
                              "maximum": 50
                            },
                            "maxPerHour": {
                              "default": 60,
                              "type": "integer",
                              "minimum": 1,
                              "maximum": 5000
                            },
                            "maxNewNumbersPerHour": {
                              "default": 30,
                              "type": "integer",
                              "minimum": 1,
                              "maximum": 1000
                            }
                          },
                          "required": ["maxConcurrent", "maxPerHour", "maxNewNumbersPerHour"],
                          "additionalProperties": false
                        },
                        "retry": {
                          "default": {
                            "maxAttempts": 3,
                            "retryOn": ["no_answer", "busy", "voicemail"],
                            "gapMinutes": 240
                          },
                          "type": "object",
                          "properties": {
                            "maxAttempts": {
                              "default": 3,
                              "type": "integer",
                              "minimum": 1,
                              "maximum": 3
                            },
                            "retryOn": {
                              "default": ["no_answer", "busy", "voicemail"],
                              "maxItems": 10,
                              "type": "array",
                              "items": {
                                "type": "string",
                                "enum": [
                                  "human",
                                  "voicemail",
                                  "fax",
                                  "no_answer",
                                  "busy",
                                  "failed",
                                  "canceled",
                                  "transferred",
                                  "opted_out",
                                  "abandoned"
                                ]
                              }
                            },
                            "gapMinutes": {
                              "default": 240,
                              "type": "integer",
                              "minimum": 240,
                              "maximum": 10080
                            }
                          },
                          "required": ["maxAttempts", "retryOn", "gapMinutes"],
                          "additionalProperties": false
                        },
                        "dataFields": {
                          "default": [],
                          "maxItems": 20,
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string",
                                "pattern": "^[a-z][a-z0-9_]{0,39}$"
                              },
                              "label": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 80
                              },
                              "type": {
                                "type": "string",
                                "enum": ["boolean", "string", "integer", "number"]
                              },
                              "description": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 500
                              },
                              "enum": {
                                "minItems": 1,
                                "maxItems": 20,
                                "type": "array",
                                "items": {
                                  "type": "string",
                                  "maxLength": 80
                                }
                              }
                            },
                            "required": ["id", "label", "type", "description"],
                            "additionalProperties": false
                          }
                        },
                        "successCriterion": {
                          "anyOf": [
                            {
                              "type": "object",
                              "properties": {
                                "all": {
                                  "minItems": 1,
                                  "maxItems": 20,
                                  "type": "array",
                                  "items": {
                                    "anyOf": [
                                      {
                                        "type": "object",
                                        "properties": {
                                          "field": {
                                            "type": "string",
                                            "pattern": "^[a-z][a-z0-9_]{0,39}$"
                                          },
                                          "op": {
                                            "type": "string",
                                            "enum": [
                                              "eq",
                                              "neq",
                                              "contains",
                                              "not_contains",
                                              "gt",
                                              "gte",
                                              "lt",
                                              "lte",
                                              "in",
                                              "exists",
                                              "not_exists"
                                            ]
                                          },
                                          "value": {
                                            "anyOf": [
                                              {
                                                "anyOf": [
                                                  {
                                                    "type": "string",
                                                    "maxLength": 500
                                                  },
                                                  {
                                                    "type": "number"
                                                  },
                                                  {
                                                    "type": "boolean"
                                                  }
                                                ]
                                              },
                                              {
                                                "maxItems": 50,
                                                "type": "array",
                                                "items": {
                                                  "anyOf": [
                                                    {
                                                      "type": "string",
                                                      "maxLength": 500
                                                    },
                                                    {
                                                      "type": "number"
                                                    },
                                                    {
                                                      "type": "boolean"
                                                    }
                                                  ]
                                                }
                                              }
                                            ]
                                          }
                                        },
                                        "required": ["field", "op"],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "event": {
                                            "type": "string",
                                            "pattern": "^[a-z][a-z0-9_]{0,63}$"
                                          }
                                        },
                                        "required": ["event"],
                                        "additionalProperties": false
                                      }
                                    ]
                                  }
                                }
                              },
                              "required": ["all"],
                              "additionalProperties": false
                            },
                            {
                              "type": "object",
                              "properties": {
                                "any": {
                                  "minItems": 1,
                                  "maxItems": 20,
                                  "type": "array",
                                  "items": {
                                    "anyOf": [
                                      {
                                        "type": "object",
                                        "properties": {
                                          "field": {
                                            "type": "string",
                                            "pattern": "^[a-z][a-z0-9_]{0,39}$"
                                          },
                                          "op": {
                                            "type": "string",
                                            "enum": [
                                              "eq",
                                              "neq",
                                              "contains",
                                              "not_contains",
                                              "gt",
                                              "gte",
                                              "lt",
                                              "lte",
                                              "in",
                                              "exists",
                                              "not_exists"
                                            ]
                                          },
                                          "value": {
                                            "anyOf": [
                                              {
                                                "anyOf": [
                                                  {
                                                    "type": "string",
                                                    "maxLength": 500
                                                  },
                                                  {
                                                    "type": "number"
                                                  },
                                                  {
                                                    "type": "boolean"
                                                  }
                                                ]
                                              },
                                              {
                                                "maxItems": 50,
                                                "type": "array",
                                                "items": {
                                                  "anyOf": [
                                                    {
                                                      "type": "string",
                                                      "maxLength": 500
                                                    },
                                                    {
                                                      "type": "number"
                                                    },
                                                    {
                                                      "type": "boolean"
                                                    }
                                                  ]
                                                }
                                              }
                                            ]
                                          }
                                        },
                                        "required": ["field", "op"],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "event": {
                                            "type": "string",
                                            "pattern": "^[a-z][a-z0-9_]{0,63}$"
                                          }
                                        },
                                        "required": ["event"],
                                        "additionalProperties": false
                                      }
                                    ]
                                  }
                                }
                              },
                              "required": ["any"],
                              "additionalProperties": false
                            }
                          ]
                        },
                        "transferRules": {
                          "default": [],
                          "maxItems": 10,
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string",
                                "pattern": "^[a-z][a-z0-9_]{0,39}$"
                              },
                              "name": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 80
                              },
                              "when": {
                                "anyOf": [
                                  {
                                    "type": "object",
                                    "properties": {
                                      "all": {
                                        "minItems": 1,
                                        "maxItems": 20,
                                        "type": "array",
                                        "items": {
                                          "anyOf": [
                                            {
                                              "type": "object",
                                              "properties": {
                                                "field": {
                                                  "type": "string",
                                                  "pattern": "^[a-z][a-z0-9_]{0,39}$"
                                                },
                                                "op": {
                                                  "type": "string",
                                                  "enum": [
                                                    "eq",
                                                    "neq",
                                                    "contains",
                                                    "not_contains",
                                                    "gt",
                                                    "gte",
                                                    "lt",
                                                    "lte",
                                                    "in",
                                                    "exists",
                                                    "not_exists"
                                                  ]
                                                },
                                                "value": {
                                                  "anyOf": [
                                                    {
                                                      "anyOf": [
                                                        {
                                                          "type": "string",
                                                          "maxLength": 500
                                                        },
                                                        {
                                                          "type": "number"
                                                        },
                                                        {
                                                          "type": "boolean"
                                                        }
                                                      ]
                                                    },
                                                    {
                                                      "maxItems": 50,
                                                      "type": "array",
                                                      "items": {
                                                        "anyOf": [
                                                          {
                                                            "type": "string",
                                                            "maxLength": 500
                                                          },
                                                          {
                                                            "type": "number"
                                                          },
                                                          {
                                                            "type": "boolean"
                                                          }
                                                        ]
                                                      }
                                                    }
                                                  ]
                                                }
                                              },
                                              "required": ["field", "op"],
                                              "additionalProperties": false
                                            },
                                            {
                                              "type": "object",
                                              "properties": {
                                                "event": {
                                                  "type": "string",
                                                  "pattern": "^[a-z][a-z0-9_]{0,63}$"
                                                }
                                              },
                                              "required": ["event"],
                                              "additionalProperties": false
                                            }
                                          ]
                                        }
                                      }
                                    },
                                    "required": ["all"],
                                    "additionalProperties": false
                                  },
                                  {
                                    "type": "object",
                                    "properties": {
                                      "any": {
                                        "minItems": 1,
                                        "maxItems": 20,
                                        "type": "array",
                                        "items": {
                                          "anyOf": [
                                            {
                                              "type": "object",
                                              "properties": {
                                                "field": {
                                                  "type": "string",
                                                  "pattern": "^[a-z][a-z0-9_]{0,39}$"
                                                },
                                                "op": {
                                                  "type": "string",
                                                  "enum": [
                                                    "eq",
                                                    "neq",
                                                    "contains",
                                                    "not_contains",
                                                    "gt",
                                                    "gte",
                                                    "lt",
                                                    "lte",
                                                    "in",
                                                    "exists",
                                                    "not_exists"
                                                  ]
                                                },
                                                "value": {
                                                  "anyOf": [
                                                    {
                                                      "anyOf": [
                                                        {
                                                          "type": "string",
                                                          "maxLength": 500
                                                        },
                                                        {
                                                          "type": "number"
                                                        },
                                                        {
                                                          "type": "boolean"
                                                        }
                                                      ]
                                                    },
                                                    {
                                                      "maxItems": 50,
                                                      "type": "array",
                                                      "items": {
                                                        "anyOf": [
                                                          {
                                                            "type": "string",
                                                            "maxLength": 500
                                                          },
                                                          {
                                                            "type": "number"
                                                          },
                                                          {
                                                            "type": "boolean"
                                                          }
                                                        ]
                                                      }
                                                    }
                                                  ]
                                                }
                                              },
                                              "required": ["field", "op"],
                                              "additionalProperties": false
                                            },
                                            {
                                              "type": "object",
                                              "properties": {
                                                "event": {
                                                  "type": "string",
                                                  "pattern": "^[a-z][a-z0-9_]{0,63}$"
                                                }
                                              },
                                              "required": ["event"],
                                              "additionalProperties": false
                                            }
                                          ]
                                        }
                                      }
                                    },
                                    "required": ["any"],
                                    "additionalProperties": false
                                  }
                                ]
                              },
                              "to": {
                                "type": "string",
                                "pattern": "^\\+[1-9]\\d{6,14}$"
                              },
                              "whisper": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 500
                              },
                              "handoffLine": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 200
                              },
                              "hours": {
                                "type": "object",
                                "properties": {
                                  "windows": {
                                    "type": "object",
                                    "properties": {
                                      "sun": {
                                        "maxItems": 4,
                                        "type": "array",
                                        "items": {
                                          "type": "array",
                                          "prefixItems": [
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            },
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            }
                                          ]
                                        }
                                      },
                                      "mon": {
                                        "maxItems": 4,
                                        "type": "array",
                                        "items": {
                                          "type": "array",
                                          "prefixItems": [
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            },
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            }
                                          ]
                                        }
                                      },
                                      "tue": {
                                        "maxItems": 4,
                                        "type": "array",
                                        "items": {
                                          "type": "array",
                                          "prefixItems": [
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            },
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            }
                                          ]
                                        }
                                      },
                                      "wed": {
                                        "maxItems": 4,
                                        "type": "array",
                                        "items": {
                                          "type": "array",
                                          "prefixItems": [
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            },
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            }
                                          ]
                                        }
                                      },
                                      "thu": {
                                        "maxItems": 4,
                                        "type": "array",
                                        "items": {
                                          "type": "array",
                                          "prefixItems": [
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            },
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            }
                                          ]
                                        }
                                      },
                                      "fri": {
                                        "maxItems": 4,
                                        "type": "array",
                                        "items": {
                                          "type": "array",
                                          "prefixItems": [
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            },
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            }
                                          ]
                                        }
                                      },
                                      "sat": {
                                        "maxItems": 4,
                                        "type": "array",
                                        "items": {
                                          "type": "array",
                                          "prefixItems": [
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            },
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            }
                                          ]
                                        }
                                      }
                                    },
                                    "additionalProperties": false
                                  },
                                  "timezone": {
                                    "type": "string",
                                    "minLength": 1,
                                    "maxLength": 64
                                  }
                                },
                                "required": ["windows", "timezone"],
                                "additionalProperties": false
                              },
                              "fallback": {
                                "default": "callback",
                                "type": "string",
                                "enum": ["callback", "end"]
                              }
                            },
                            "required": [
                              "id",
                              "name",
                              "when",
                              "to",
                              "whisper",
                              "handoffLine",
                              "fallback"
                            ],
                            "additionalProperties": false
                          }
                        }
                      },
                      "required": [
                        "brief",
                        "purposeLine",
                        "schedule",
                        "pacing",
                        "retry",
                        "dataFields",
                        "transferRules"
                      ],
                      "additionalProperties": false
                    },
                    "requiredVariables": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "settingsConfirmedBy": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "pausedReason": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "createdBy": {
                      "type": "string"
                    },
                    "launchedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "completedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "createdAt": {
                      "type": "string"
                    },
                    "updatedAt": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "id",
                    "orgId",
                    "name",
                    "purpose",
                    "status",
                    "alwaysOn",
                    "priority",
                    "inboxId",
                    "settings",
                    "requiredVariables",
                    "settingsConfirmedBy",
                    "pausedReason",
                    "createdBy",
                    "launchedAt",
                    "completedAt",
                    "createdAt",
                    "updatedAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/outbound/campaigns/{id}/pause": {
      "post": {
        "operationId": "outbound-campaigns-pause",
        "summary": "Pause an outbound campaign",
        "tags": ["Outbound"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 128
            },
            "required": true
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "reason": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 500
                  }
                },
                "required": ["orgId"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 128
                    },
                    "orgId": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "purpose": {
                      "type": "string",
                      "enum": ["marketing", "lead_followup", "service"]
                    },
                    "status": {
                      "type": "string",
                      "enum": ["draft", "launching", "running", "paused", "completed", "archived"]
                    },
                    "alwaysOn": {
                      "type": "boolean"
                    },
                    "priority": {
                      "type": "number"
                    },
                    "inboxId": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 128
                    },
                    "settings": {
                      "type": "object",
                      "properties": {
                        "brief": {
                          "default": "",
                          "type": "string",
                          "maxLength": 4000
                        },
                        "purposeLine": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 200
                        },
                        "addressOrFreephone": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 200
                        },
                        "schedule": {
                          "default": {},
                          "type": "object",
                          "properties": {
                            "startAt": {
                              "type": "string",
                              "format": "date-time",
                              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                            },
                            "endAt": {
                              "type": "string",
                              "format": "date-time",
                              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                            },
                            "windows": {
                              "type": "object",
                              "properties": {
                                "sun": {
                                  "maxItems": 4,
                                  "type": "array",
                                  "items": {
                                    "type": "array",
                                    "prefixItems": [
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      },
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      }
                                    ]
                                  }
                                },
                                "mon": {
                                  "maxItems": 4,
                                  "type": "array",
                                  "items": {
                                    "type": "array",
                                    "prefixItems": [
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      },
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      }
                                    ]
                                  }
                                },
                                "tue": {
                                  "maxItems": 4,
                                  "type": "array",
                                  "items": {
                                    "type": "array",
                                    "prefixItems": [
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      },
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      }
                                    ]
                                  }
                                },
                                "wed": {
                                  "maxItems": 4,
                                  "type": "array",
                                  "items": {
                                    "type": "array",
                                    "prefixItems": [
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      },
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      }
                                    ]
                                  }
                                },
                                "thu": {
                                  "maxItems": 4,
                                  "type": "array",
                                  "items": {
                                    "type": "array",
                                    "prefixItems": [
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      },
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      }
                                    ]
                                  }
                                },
                                "fri": {
                                  "maxItems": 4,
                                  "type": "array",
                                  "items": {
                                    "type": "array",
                                    "prefixItems": [
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      },
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      }
                                    ]
                                  }
                                },
                                "sat": {
                                  "maxItems": 4,
                                  "type": "array",
                                  "items": {
                                    "type": "array",
                                    "prefixItems": [
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      },
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      }
                                    ]
                                  }
                                }
                              },
                              "additionalProperties": false
                            }
                          },
                          "additionalProperties": false
                        },
                        "pacing": {
                          "default": {
                            "maxConcurrent": 2,
                            "maxPerHour": 60,
                            "maxNewNumbersPerHour": 30
                          },
                          "type": "object",
                          "properties": {
                            "maxConcurrent": {
                              "default": 2,
                              "type": "integer",
                              "minimum": 1,
                              "maximum": 50
                            },
                            "maxPerHour": {
                              "default": 60,
                              "type": "integer",
                              "minimum": 1,
                              "maximum": 5000
                            },
                            "maxNewNumbersPerHour": {
                              "default": 30,
                              "type": "integer",
                              "minimum": 1,
                              "maximum": 1000
                            }
                          },
                          "required": ["maxConcurrent", "maxPerHour", "maxNewNumbersPerHour"],
                          "additionalProperties": false
                        },
                        "retry": {
                          "default": {
                            "maxAttempts": 3,
                            "retryOn": ["no_answer", "busy", "voicemail"],
                            "gapMinutes": 240
                          },
                          "type": "object",
                          "properties": {
                            "maxAttempts": {
                              "default": 3,
                              "type": "integer",
                              "minimum": 1,
                              "maximum": 3
                            },
                            "retryOn": {
                              "default": ["no_answer", "busy", "voicemail"],
                              "maxItems": 10,
                              "type": "array",
                              "items": {
                                "type": "string",
                                "enum": [
                                  "human",
                                  "voicemail",
                                  "fax",
                                  "no_answer",
                                  "busy",
                                  "failed",
                                  "canceled",
                                  "transferred",
                                  "opted_out",
                                  "abandoned"
                                ]
                              }
                            },
                            "gapMinutes": {
                              "default": 240,
                              "type": "integer",
                              "minimum": 240,
                              "maximum": 10080
                            }
                          },
                          "required": ["maxAttempts", "retryOn", "gapMinutes"],
                          "additionalProperties": false
                        },
                        "dataFields": {
                          "default": [],
                          "maxItems": 20,
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string",
                                "pattern": "^[a-z][a-z0-9_]{0,39}$"
                              },
                              "label": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 80
                              },
                              "type": {
                                "type": "string",
                                "enum": ["boolean", "string", "integer", "number"]
                              },
                              "description": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 500
                              },
                              "enum": {
                                "minItems": 1,
                                "maxItems": 20,
                                "type": "array",
                                "items": {
                                  "type": "string",
                                  "maxLength": 80
                                }
                              }
                            },
                            "required": ["id", "label", "type", "description"],
                            "additionalProperties": false
                          }
                        },
                        "successCriterion": {
                          "anyOf": [
                            {
                              "type": "object",
                              "properties": {
                                "all": {
                                  "minItems": 1,
                                  "maxItems": 20,
                                  "type": "array",
                                  "items": {
                                    "anyOf": [
                                      {
                                        "type": "object",
                                        "properties": {
                                          "field": {
                                            "type": "string",
                                            "pattern": "^[a-z][a-z0-9_]{0,39}$"
                                          },
                                          "op": {
                                            "type": "string",
                                            "enum": [
                                              "eq",
                                              "neq",
                                              "contains",
                                              "not_contains",
                                              "gt",
                                              "gte",
                                              "lt",
                                              "lte",
                                              "in",
                                              "exists",
                                              "not_exists"
                                            ]
                                          },
                                          "value": {
                                            "anyOf": [
                                              {
                                                "anyOf": [
                                                  {
                                                    "type": "string",
                                                    "maxLength": 500
                                                  },
                                                  {
                                                    "type": "number"
                                                  },
                                                  {
                                                    "type": "boolean"
                                                  }
                                                ]
                                              },
                                              {
                                                "maxItems": 50,
                                                "type": "array",
                                                "items": {
                                                  "anyOf": [
                                                    {
                                                      "type": "string",
                                                      "maxLength": 500
                                                    },
                                                    {
                                                      "type": "number"
                                                    },
                                                    {
                                                      "type": "boolean"
                                                    }
                                                  ]
                                                }
                                              }
                                            ]
                                          }
                                        },
                                        "required": ["field", "op"],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "event": {
                                            "type": "string",
                                            "pattern": "^[a-z][a-z0-9_]{0,63}$"
                                          }
                                        },
                                        "required": ["event"],
                                        "additionalProperties": false
                                      }
                                    ]
                                  }
                                }
                              },
                              "required": ["all"],
                              "additionalProperties": false
                            },
                            {
                              "type": "object",
                              "properties": {
                                "any": {
                                  "minItems": 1,
                                  "maxItems": 20,
                                  "type": "array",
                                  "items": {
                                    "anyOf": [
                                      {
                                        "type": "object",
                                        "properties": {
                                          "field": {
                                            "type": "string",
                                            "pattern": "^[a-z][a-z0-9_]{0,39}$"
                                          },
                                          "op": {
                                            "type": "string",
                                            "enum": [
                                              "eq",
                                              "neq",
                                              "contains",
                                              "not_contains",
                                              "gt",
                                              "gte",
                                              "lt",
                                              "lte",
                                              "in",
                                              "exists",
                                              "not_exists"
                                            ]
                                          },
                                          "value": {
                                            "anyOf": [
                                              {
                                                "anyOf": [
                                                  {
                                                    "type": "string",
                                                    "maxLength": 500
                                                  },
                                                  {
                                                    "type": "number"
                                                  },
                                                  {
                                                    "type": "boolean"
                                                  }
                                                ]
                                              },
                                              {
                                                "maxItems": 50,
                                                "type": "array",
                                                "items": {
                                                  "anyOf": [
                                                    {
                                                      "type": "string",
                                                      "maxLength": 500
                                                    },
                                                    {
                                                      "type": "number"
                                                    },
                                                    {
                                                      "type": "boolean"
                                                    }
                                                  ]
                                                }
                                              }
                                            ]
                                          }
                                        },
                                        "required": ["field", "op"],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "event": {
                                            "type": "string",
                                            "pattern": "^[a-z][a-z0-9_]{0,63}$"
                                          }
                                        },
                                        "required": ["event"],
                                        "additionalProperties": false
                                      }
                                    ]
                                  }
                                }
                              },
                              "required": ["any"],
                              "additionalProperties": false
                            }
                          ]
                        },
                        "transferRules": {
                          "default": [],
                          "maxItems": 10,
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string",
                                "pattern": "^[a-z][a-z0-9_]{0,39}$"
                              },
                              "name": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 80
                              },
                              "when": {
                                "anyOf": [
                                  {
                                    "type": "object",
                                    "properties": {
                                      "all": {
                                        "minItems": 1,
                                        "maxItems": 20,
                                        "type": "array",
                                        "items": {
                                          "anyOf": [
                                            {
                                              "type": "object",
                                              "properties": {
                                                "field": {
                                                  "type": "string",
                                                  "pattern": "^[a-z][a-z0-9_]{0,39}$"
                                                },
                                                "op": {
                                                  "type": "string",
                                                  "enum": [
                                                    "eq",
                                                    "neq",
                                                    "contains",
                                                    "not_contains",
                                                    "gt",
                                                    "gte",
                                                    "lt",
                                                    "lte",
                                                    "in",
                                                    "exists",
                                                    "not_exists"
                                                  ]
                                                },
                                                "value": {
                                                  "anyOf": [
                                                    {
                                                      "anyOf": [
                                                        {
                                                          "type": "string",
                                                          "maxLength": 500
                                                        },
                                                        {
                                                          "type": "number"
                                                        },
                                                        {
                                                          "type": "boolean"
                                                        }
                                                      ]
                                                    },
                                                    {
                                                      "maxItems": 50,
                                                      "type": "array",
                                                      "items": {
                                                        "anyOf": [
                                                          {
                                                            "type": "string",
                                                            "maxLength": 500
                                                          },
                                                          {
                                                            "type": "number"
                                                          },
                                                          {
                                                            "type": "boolean"
                                                          }
                                                        ]
                                                      }
                                                    }
                                                  ]
                                                }
                                              },
                                              "required": ["field", "op"],
                                              "additionalProperties": false
                                            },
                                            {
                                              "type": "object",
                                              "properties": {
                                                "event": {
                                                  "type": "string",
                                                  "pattern": "^[a-z][a-z0-9_]{0,63}$"
                                                }
                                              },
                                              "required": ["event"],
                                              "additionalProperties": false
                                            }
                                          ]
                                        }
                                      }
                                    },
                                    "required": ["all"],
                                    "additionalProperties": false
                                  },
                                  {
                                    "type": "object",
                                    "properties": {
                                      "any": {
                                        "minItems": 1,
                                        "maxItems": 20,
                                        "type": "array",
                                        "items": {
                                          "anyOf": [
                                            {
                                              "type": "object",
                                              "properties": {
                                                "field": {
                                                  "type": "string",
                                                  "pattern": "^[a-z][a-z0-9_]{0,39}$"
                                                },
                                                "op": {
                                                  "type": "string",
                                                  "enum": [
                                                    "eq",
                                                    "neq",
                                                    "contains",
                                                    "not_contains",
                                                    "gt",
                                                    "gte",
                                                    "lt",
                                                    "lte",
                                                    "in",
                                                    "exists",
                                                    "not_exists"
                                                  ]
                                                },
                                                "value": {
                                                  "anyOf": [
                                                    {
                                                      "anyOf": [
                                                        {
                                                          "type": "string",
                                                          "maxLength": 500
                                                        },
                                                        {
                                                          "type": "number"
                                                        },
                                                        {
                                                          "type": "boolean"
                                                        }
                                                      ]
                                                    },
                                                    {
                                                      "maxItems": 50,
                                                      "type": "array",
                                                      "items": {
                                                        "anyOf": [
                                                          {
                                                            "type": "string",
                                                            "maxLength": 500
                                                          },
                                                          {
                                                            "type": "number"
                                                          },
                                                          {
                                                            "type": "boolean"
                                                          }
                                                        ]
                                                      }
                                                    }
                                                  ]
                                                }
                                              },
                                              "required": ["field", "op"],
                                              "additionalProperties": false
                                            },
                                            {
                                              "type": "object",
                                              "properties": {
                                                "event": {
                                                  "type": "string",
                                                  "pattern": "^[a-z][a-z0-9_]{0,63}$"
                                                }
                                              },
                                              "required": ["event"],
                                              "additionalProperties": false
                                            }
                                          ]
                                        }
                                      }
                                    },
                                    "required": ["any"],
                                    "additionalProperties": false
                                  }
                                ]
                              },
                              "to": {
                                "type": "string",
                                "pattern": "^\\+[1-9]\\d{6,14}$"
                              },
                              "whisper": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 500
                              },
                              "handoffLine": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 200
                              },
                              "hours": {
                                "type": "object",
                                "properties": {
                                  "windows": {
                                    "type": "object",
                                    "properties": {
                                      "sun": {
                                        "maxItems": 4,
                                        "type": "array",
                                        "items": {
                                          "type": "array",
                                          "prefixItems": [
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            },
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            }
                                          ]
                                        }
                                      },
                                      "mon": {
                                        "maxItems": 4,
                                        "type": "array",
                                        "items": {
                                          "type": "array",
                                          "prefixItems": [
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            },
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            }
                                          ]
                                        }
                                      },
                                      "tue": {
                                        "maxItems": 4,
                                        "type": "array",
                                        "items": {
                                          "type": "array",
                                          "prefixItems": [
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            },
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            }
                                          ]
                                        }
                                      },
                                      "wed": {
                                        "maxItems": 4,
                                        "type": "array",
                                        "items": {
                                          "type": "array",
                                          "prefixItems": [
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            },
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            }
                                          ]
                                        }
                                      },
                                      "thu": {
                                        "maxItems": 4,
                                        "type": "array",
                                        "items": {
                                          "type": "array",
                                          "prefixItems": [
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            },
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            }
                                          ]
                                        }
                                      },
                                      "fri": {
                                        "maxItems": 4,
                                        "type": "array",
                                        "items": {
                                          "type": "array",
                                          "prefixItems": [
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            },
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            }
                                          ]
                                        }
                                      },
                                      "sat": {
                                        "maxItems": 4,
                                        "type": "array",
                                        "items": {
                                          "type": "array",
                                          "prefixItems": [
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            },
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            }
                                          ]
                                        }
                                      }
                                    },
                                    "additionalProperties": false
                                  },
                                  "timezone": {
                                    "type": "string",
                                    "minLength": 1,
                                    "maxLength": 64
                                  }
                                },
                                "required": ["windows", "timezone"],
                                "additionalProperties": false
                              },
                              "fallback": {
                                "default": "callback",
                                "type": "string",
                                "enum": ["callback", "end"]
                              }
                            },
                            "required": [
                              "id",
                              "name",
                              "when",
                              "to",
                              "whisper",
                              "handoffLine",
                              "fallback"
                            ],
                            "additionalProperties": false
                          }
                        }
                      },
                      "required": [
                        "brief",
                        "purposeLine",
                        "schedule",
                        "pacing",
                        "retry",
                        "dataFields",
                        "transferRules"
                      ],
                      "additionalProperties": false
                    },
                    "requiredVariables": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "settingsConfirmedBy": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "pausedReason": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "createdBy": {
                      "type": "string"
                    },
                    "launchedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "completedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "createdAt": {
                      "type": "string"
                    },
                    "updatedAt": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "id",
                    "orgId",
                    "name",
                    "purpose",
                    "status",
                    "alwaysOn",
                    "priority",
                    "inboxId",
                    "settings",
                    "requiredVariables",
                    "settingsConfirmedBy",
                    "pausedReason",
                    "createdBy",
                    "launchedAt",
                    "completedAt",
                    "createdAt",
                    "updatedAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/outbound/campaigns/{id}/resume": {
      "post": {
        "operationId": "outbound-campaigns-resume",
        "summary": "Resume an outbound campaign",
        "tags": ["Outbound"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 128
            },
            "required": true
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  }
                },
                "required": ["orgId"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 128
                    },
                    "orgId": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "purpose": {
                      "type": "string",
                      "enum": ["marketing", "lead_followup", "service"]
                    },
                    "status": {
                      "type": "string",
                      "enum": ["draft", "launching", "running", "paused", "completed", "archived"]
                    },
                    "alwaysOn": {
                      "type": "boolean"
                    },
                    "priority": {
                      "type": "number"
                    },
                    "inboxId": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 128
                    },
                    "settings": {
                      "type": "object",
                      "properties": {
                        "brief": {
                          "default": "",
                          "type": "string",
                          "maxLength": 4000
                        },
                        "purposeLine": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 200
                        },
                        "addressOrFreephone": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 200
                        },
                        "schedule": {
                          "default": {},
                          "type": "object",
                          "properties": {
                            "startAt": {
                              "type": "string",
                              "format": "date-time",
                              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                            },
                            "endAt": {
                              "type": "string",
                              "format": "date-time",
                              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                            },
                            "windows": {
                              "type": "object",
                              "properties": {
                                "sun": {
                                  "maxItems": 4,
                                  "type": "array",
                                  "items": {
                                    "type": "array",
                                    "prefixItems": [
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      },
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      }
                                    ]
                                  }
                                },
                                "mon": {
                                  "maxItems": 4,
                                  "type": "array",
                                  "items": {
                                    "type": "array",
                                    "prefixItems": [
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      },
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      }
                                    ]
                                  }
                                },
                                "tue": {
                                  "maxItems": 4,
                                  "type": "array",
                                  "items": {
                                    "type": "array",
                                    "prefixItems": [
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      },
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      }
                                    ]
                                  }
                                },
                                "wed": {
                                  "maxItems": 4,
                                  "type": "array",
                                  "items": {
                                    "type": "array",
                                    "prefixItems": [
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      },
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      }
                                    ]
                                  }
                                },
                                "thu": {
                                  "maxItems": 4,
                                  "type": "array",
                                  "items": {
                                    "type": "array",
                                    "prefixItems": [
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      },
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      }
                                    ]
                                  }
                                },
                                "fri": {
                                  "maxItems": 4,
                                  "type": "array",
                                  "items": {
                                    "type": "array",
                                    "prefixItems": [
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      },
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      }
                                    ]
                                  }
                                },
                                "sat": {
                                  "maxItems": 4,
                                  "type": "array",
                                  "items": {
                                    "type": "array",
                                    "prefixItems": [
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      },
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      }
                                    ]
                                  }
                                }
                              },
                              "additionalProperties": false
                            }
                          },
                          "additionalProperties": false
                        },
                        "pacing": {
                          "default": {
                            "maxConcurrent": 2,
                            "maxPerHour": 60,
                            "maxNewNumbersPerHour": 30
                          },
                          "type": "object",
                          "properties": {
                            "maxConcurrent": {
                              "default": 2,
                              "type": "integer",
                              "minimum": 1,
                              "maximum": 50
                            },
                            "maxPerHour": {
                              "default": 60,
                              "type": "integer",
                              "minimum": 1,
                              "maximum": 5000
                            },
                            "maxNewNumbersPerHour": {
                              "default": 30,
                              "type": "integer",
                              "minimum": 1,
                              "maximum": 1000
                            }
                          },
                          "required": ["maxConcurrent", "maxPerHour", "maxNewNumbersPerHour"],
                          "additionalProperties": false
                        },
                        "retry": {
                          "default": {
                            "maxAttempts": 3,
                            "retryOn": ["no_answer", "busy", "voicemail"],
                            "gapMinutes": 240
                          },
                          "type": "object",
                          "properties": {
                            "maxAttempts": {
                              "default": 3,
                              "type": "integer",
                              "minimum": 1,
                              "maximum": 3
                            },
                            "retryOn": {
                              "default": ["no_answer", "busy", "voicemail"],
                              "maxItems": 10,
                              "type": "array",
                              "items": {
                                "type": "string",
                                "enum": [
                                  "human",
                                  "voicemail",
                                  "fax",
                                  "no_answer",
                                  "busy",
                                  "failed",
                                  "canceled",
                                  "transferred",
                                  "opted_out",
                                  "abandoned"
                                ]
                              }
                            },
                            "gapMinutes": {
                              "default": 240,
                              "type": "integer",
                              "minimum": 240,
                              "maximum": 10080
                            }
                          },
                          "required": ["maxAttempts", "retryOn", "gapMinutes"],
                          "additionalProperties": false
                        },
                        "dataFields": {
                          "default": [],
                          "maxItems": 20,
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string",
                                "pattern": "^[a-z][a-z0-9_]{0,39}$"
                              },
                              "label": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 80
                              },
                              "type": {
                                "type": "string",
                                "enum": ["boolean", "string", "integer", "number"]
                              },
                              "description": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 500
                              },
                              "enum": {
                                "minItems": 1,
                                "maxItems": 20,
                                "type": "array",
                                "items": {
                                  "type": "string",
                                  "maxLength": 80
                                }
                              }
                            },
                            "required": ["id", "label", "type", "description"],
                            "additionalProperties": false
                          }
                        },
                        "successCriterion": {
                          "anyOf": [
                            {
                              "type": "object",
                              "properties": {
                                "all": {
                                  "minItems": 1,
                                  "maxItems": 20,
                                  "type": "array",
                                  "items": {
                                    "anyOf": [
                                      {
                                        "type": "object",
                                        "properties": {
                                          "field": {
                                            "type": "string",
                                            "pattern": "^[a-z][a-z0-9_]{0,39}$"
                                          },
                                          "op": {
                                            "type": "string",
                                            "enum": [
                                              "eq",
                                              "neq",
                                              "contains",
                                              "not_contains",
                                              "gt",
                                              "gte",
                                              "lt",
                                              "lte",
                                              "in",
                                              "exists",
                                              "not_exists"
                                            ]
                                          },
                                          "value": {
                                            "anyOf": [
                                              {
                                                "anyOf": [
                                                  {
                                                    "type": "string",
                                                    "maxLength": 500
                                                  },
                                                  {
                                                    "type": "number"
                                                  },
                                                  {
                                                    "type": "boolean"
                                                  }
                                                ]
                                              },
                                              {
                                                "maxItems": 50,
                                                "type": "array",
                                                "items": {
                                                  "anyOf": [
                                                    {
                                                      "type": "string",
                                                      "maxLength": 500
                                                    },
                                                    {
                                                      "type": "number"
                                                    },
                                                    {
                                                      "type": "boolean"
                                                    }
                                                  ]
                                                }
                                              }
                                            ]
                                          }
                                        },
                                        "required": ["field", "op"],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "event": {
                                            "type": "string",
                                            "pattern": "^[a-z][a-z0-9_]{0,63}$"
                                          }
                                        },
                                        "required": ["event"],
                                        "additionalProperties": false
                                      }
                                    ]
                                  }
                                }
                              },
                              "required": ["all"],
                              "additionalProperties": false
                            },
                            {
                              "type": "object",
                              "properties": {
                                "any": {
                                  "minItems": 1,
                                  "maxItems": 20,
                                  "type": "array",
                                  "items": {
                                    "anyOf": [
                                      {
                                        "type": "object",
                                        "properties": {
                                          "field": {
                                            "type": "string",
                                            "pattern": "^[a-z][a-z0-9_]{0,39}$"
                                          },
                                          "op": {
                                            "type": "string",
                                            "enum": [
                                              "eq",
                                              "neq",
                                              "contains",
                                              "not_contains",
                                              "gt",
                                              "gte",
                                              "lt",
                                              "lte",
                                              "in",
                                              "exists",
                                              "not_exists"
                                            ]
                                          },
                                          "value": {
                                            "anyOf": [
                                              {
                                                "anyOf": [
                                                  {
                                                    "type": "string",
                                                    "maxLength": 500
                                                  },
                                                  {
                                                    "type": "number"
                                                  },
                                                  {
                                                    "type": "boolean"
                                                  }
                                                ]
                                              },
                                              {
                                                "maxItems": 50,
                                                "type": "array",
                                                "items": {
                                                  "anyOf": [
                                                    {
                                                      "type": "string",
                                                      "maxLength": 500
                                                    },
                                                    {
                                                      "type": "number"
                                                    },
                                                    {
                                                      "type": "boolean"
                                                    }
                                                  ]
                                                }
                                              }
                                            ]
                                          }
                                        },
                                        "required": ["field", "op"],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "event": {
                                            "type": "string",
                                            "pattern": "^[a-z][a-z0-9_]{0,63}$"
                                          }
                                        },
                                        "required": ["event"],
                                        "additionalProperties": false
                                      }
                                    ]
                                  }
                                }
                              },
                              "required": ["any"],
                              "additionalProperties": false
                            }
                          ]
                        },
                        "transferRules": {
                          "default": [],
                          "maxItems": 10,
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string",
                                "pattern": "^[a-z][a-z0-9_]{0,39}$"
                              },
                              "name": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 80
                              },
                              "when": {
                                "anyOf": [
                                  {
                                    "type": "object",
                                    "properties": {
                                      "all": {
                                        "minItems": 1,
                                        "maxItems": 20,
                                        "type": "array",
                                        "items": {
                                          "anyOf": [
                                            {
                                              "type": "object",
                                              "properties": {
                                                "field": {
                                                  "type": "string",
                                                  "pattern": "^[a-z][a-z0-9_]{0,39}$"
                                                },
                                                "op": {
                                                  "type": "string",
                                                  "enum": [
                                                    "eq",
                                                    "neq",
                                                    "contains",
                                                    "not_contains",
                                                    "gt",
                                                    "gte",
                                                    "lt",
                                                    "lte",
                                                    "in",
                                                    "exists",
                                                    "not_exists"
                                                  ]
                                                },
                                                "value": {
                                                  "anyOf": [
                                                    {
                                                      "anyOf": [
                                                        {
                                                          "type": "string",
                                                          "maxLength": 500
                                                        },
                                                        {
                                                          "type": "number"
                                                        },
                                                        {
                                                          "type": "boolean"
                                                        }
                                                      ]
                                                    },
                                                    {
                                                      "maxItems": 50,
                                                      "type": "array",
                                                      "items": {
                                                        "anyOf": [
                                                          {
                                                            "type": "string",
                                                            "maxLength": 500
                                                          },
                                                          {
                                                            "type": "number"
                                                          },
                                                          {
                                                            "type": "boolean"
                                                          }
                                                        ]
                                                      }
                                                    }
                                                  ]
                                                }
                                              },
                                              "required": ["field", "op"],
                                              "additionalProperties": false
                                            },
                                            {
                                              "type": "object",
                                              "properties": {
                                                "event": {
                                                  "type": "string",
                                                  "pattern": "^[a-z][a-z0-9_]{0,63}$"
                                                }
                                              },
                                              "required": ["event"],
                                              "additionalProperties": false
                                            }
                                          ]
                                        }
                                      }
                                    },
                                    "required": ["all"],
                                    "additionalProperties": false
                                  },
                                  {
                                    "type": "object",
                                    "properties": {
                                      "any": {
                                        "minItems": 1,
                                        "maxItems": 20,
                                        "type": "array",
                                        "items": {
                                          "anyOf": [
                                            {
                                              "type": "object",
                                              "properties": {
                                                "field": {
                                                  "type": "string",
                                                  "pattern": "^[a-z][a-z0-9_]{0,39}$"
                                                },
                                                "op": {
                                                  "type": "string",
                                                  "enum": [
                                                    "eq",
                                                    "neq",
                                                    "contains",
                                                    "not_contains",
                                                    "gt",
                                                    "gte",
                                                    "lt",
                                                    "lte",
                                                    "in",
                                                    "exists",
                                                    "not_exists"
                                                  ]
                                                },
                                                "value": {
                                                  "anyOf": [
                                                    {
                                                      "anyOf": [
                                                        {
                                                          "type": "string",
                                                          "maxLength": 500
                                                        },
                                                        {
                                                          "type": "number"
                                                        },
                                                        {
                                                          "type": "boolean"
                                                        }
                                                      ]
                                                    },
                                                    {
                                                      "maxItems": 50,
                                                      "type": "array",
                                                      "items": {
                                                        "anyOf": [
                                                          {
                                                            "type": "string",
                                                            "maxLength": 500
                                                          },
                                                          {
                                                            "type": "number"
                                                          },
                                                          {
                                                            "type": "boolean"
                                                          }
                                                        ]
                                                      }
                                                    }
                                                  ]
                                                }
                                              },
                                              "required": ["field", "op"],
                                              "additionalProperties": false
                                            },
                                            {
                                              "type": "object",
                                              "properties": {
                                                "event": {
                                                  "type": "string",
                                                  "pattern": "^[a-z][a-z0-9_]{0,63}$"
                                                }
                                              },
                                              "required": ["event"],
                                              "additionalProperties": false
                                            }
                                          ]
                                        }
                                      }
                                    },
                                    "required": ["any"],
                                    "additionalProperties": false
                                  }
                                ]
                              },
                              "to": {
                                "type": "string",
                                "pattern": "^\\+[1-9]\\d{6,14}$"
                              },
                              "whisper": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 500
                              },
                              "handoffLine": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 200
                              },
                              "hours": {
                                "type": "object",
                                "properties": {
                                  "windows": {
                                    "type": "object",
                                    "properties": {
                                      "sun": {
                                        "maxItems": 4,
                                        "type": "array",
                                        "items": {
                                          "type": "array",
                                          "prefixItems": [
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            },
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            }
                                          ]
                                        }
                                      },
                                      "mon": {
                                        "maxItems": 4,
                                        "type": "array",
                                        "items": {
                                          "type": "array",
                                          "prefixItems": [
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            },
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            }
                                          ]
                                        }
                                      },
                                      "tue": {
                                        "maxItems": 4,
                                        "type": "array",
                                        "items": {
                                          "type": "array",
                                          "prefixItems": [
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            },
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            }
                                          ]
                                        }
                                      },
                                      "wed": {
                                        "maxItems": 4,
                                        "type": "array",
                                        "items": {
                                          "type": "array",
                                          "prefixItems": [
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            },
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            }
                                          ]
                                        }
                                      },
                                      "thu": {
                                        "maxItems": 4,
                                        "type": "array",
                                        "items": {
                                          "type": "array",
                                          "prefixItems": [
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            },
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            }
                                          ]
                                        }
                                      },
                                      "fri": {
                                        "maxItems": 4,
                                        "type": "array",
                                        "items": {
                                          "type": "array",
                                          "prefixItems": [
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            },
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            }
                                          ]
                                        }
                                      },
                                      "sat": {
                                        "maxItems": 4,
                                        "type": "array",
                                        "items": {
                                          "type": "array",
                                          "prefixItems": [
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            },
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            }
                                          ]
                                        }
                                      }
                                    },
                                    "additionalProperties": false
                                  },
                                  "timezone": {
                                    "type": "string",
                                    "minLength": 1,
                                    "maxLength": 64
                                  }
                                },
                                "required": ["windows", "timezone"],
                                "additionalProperties": false
                              },
                              "fallback": {
                                "default": "callback",
                                "type": "string",
                                "enum": ["callback", "end"]
                              }
                            },
                            "required": [
                              "id",
                              "name",
                              "when",
                              "to",
                              "whisper",
                              "handoffLine",
                              "fallback"
                            ],
                            "additionalProperties": false
                          }
                        }
                      },
                      "required": [
                        "brief",
                        "purposeLine",
                        "schedule",
                        "pacing",
                        "retry",
                        "dataFields",
                        "transferRules"
                      ],
                      "additionalProperties": false
                    },
                    "requiredVariables": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "settingsConfirmedBy": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "pausedReason": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "createdBy": {
                      "type": "string"
                    },
                    "launchedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "completedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "createdAt": {
                      "type": "string"
                    },
                    "updatedAt": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "id",
                    "orgId",
                    "name",
                    "purpose",
                    "status",
                    "alwaysOn",
                    "priority",
                    "inboxId",
                    "settings",
                    "requiredVariables",
                    "settingsConfirmedBy",
                    "pausedReason",
                    "createdBy",
                    "launchedAt",
                    "completedAt",
                    "createdAt",
                    "updatedAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/outbound/campaigns/{id}/complete": {
      "post": {
        "operationId": "outbound-campaigns-complete",
        "summary": "Complete a campaign and cancel queued requests",
        "tags": ["Outbound"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 128
            },
            "required": true
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  }
                },
                "required": ["orgId"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 128
                    },
                    "orgId": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "purpose": {
                      "type": "string",
                      "enum": ["marketing", "lead_followup", "service"]
                    },
                    "status": {
                      "type": "string",
                      "enum": ["draft", "launching", "running", "paused", "completed", "archived"]
                    },
                    "alwaysOn": {
                      "type": "boolean"
                    },
                    "priority": {
                      "type": "number"
                    },
                    "inboxId": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 128
                    },
                    "settings": {
                      "type": "object",
                      "properties": {
                        "brief": {
                          "default": "",
                          "type": "string",
                          "maxLength": 4000
                        },
                        "purposeLine": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 200
                        },
                        "addressOrFreephone": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 200
                        },
                        "schedule": {
                          "default": {},
                          "type": "object",
                          "properties": {
                            "startAt": {
                              "type": "string",
                              "format": "date-time",
                              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                            },
                            "endAt": {
                              "type": "string",
                              "format": "date-time",
                              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                            },
                            "windows": {
                              "type": "object",
                              "properties": {
                                "sun": {
                                  "maxItems": 4,
                                  "type": "array",
                                  "items": {
                                    "type": "array",
                                    "prefixItems": [
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      },
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      }
                                    ]
                                  }
                                },
                                "mon": {
                                  "maxItems": 4,
                                  "type": "array",
                                  "items": {
                                    "type": "array",
                                    "prefixItems": [
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      },
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      }
                                    ]
                                  }
                                },
                                "tue": {
                                  "maxItems": 4,
                                  "type": "array",
                                  "items": {
                                    "type": "array",
                                    "prefixItems": [
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      },
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      }
                                    ]
                                  }
                                },
                                "wed": {
                                  "maxItems": 4,
                                  "type": "array",
                                  "items": {
                                    "type": "array",
                                    "prefixItems": [
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      },
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      }
                                    ]
                                  }
                                },
                                "thu": {
                                  "maxItems": 4,
                                  "type": "array",
                                  "items": {
                                    "type": "array",
                                    "prefixItems": [
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      },
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      }
                                    ]
                                  }
                                },
                                "fri": {
                                  "maxItems": 4,
                                  "type": "array",
                                  "items": {
                                    "type": "array",
                                    "prefixItems": [
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      },
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      }
                                    ]
                                  }
                                },
                                "sat": {
                                  "maxItems": 4,
                                  "type": "array",
                                  "items": {
                                    "type": "array",
                                    "prefixItems": [
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      },
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      }
                                    ]
                                  }
                                }
                              },
                              "additionalProperties": false
                            }
                          },
                          "additionalProperties": false
                        },
                        "pacing": {
                          "default": {
                            "maxConcurrent": 2,
                            "maxPerHour": 60,
                            "maxNewNumbersPerHour": 30
                          },
                          "type": "object",
                          "properties": {
                            "maxConcurrent": {
                              "default": 2,
                              "type": "integer",
                              "minimum": 1,
                              "maximum": 50
                            },
                            "maxPerHour": {
                              "default": 60,
                              "type": "integer",
                              "minimum": 1,
                              "maximum": 5000
                            },
                            "maxNewNumbersPerHour": {
                              "default": 30,
                              "type": "integer",
                              "minimum": 1,
                              "maximum": 1000
                            }
                          },
                          "required": ["maxConcurrent", "maxPerHour", "maxNewNumbersPerHour"],
                          "additionalProperties": false
                        },
                        "retry": {
                          "default": {
                            "maxAttempts": 3,
                            "retryOn": ["no_answer", "busy", "voicemail"],
                            "gapMinutes": 240
                          },
                          "type": "object",
                          "properties": {
                            "maxAttempts": {
                              "default": 3,
                              "type": "integer",
                              "minimum": 1,
                              "maximum": 3
                            },
                            "retryOn": {
                              "default": ["no_answer", "busy", "voicemail"],
                              "maxItems": 10,
                              "type": "array",
                              "items": {
                                "type": "string",
                                "enum": [
                                  "human",
                                  "voicemail",
                                  "fax",
                                  "no_answer",
                                  "busy",
                                  "failed",
                                  "canceled",
                                  "transferred",
                                  "opted_out",
                                  "abandoned"
                                ]
                              }
                            },
                            "gapMinutes": {
                              "default": 240,
                              "type": "integer",
                              "minimum": 240,
                              "maximum": 10080
                            }
                          },
                          "required": ["maxAttempts", "retryOn", "gapMinutes"],
                          "additionalProperties": false
                        },
                        "dataFields": {
                          "default": [],
                          "maxItems": 20,
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string",
                                "pattern": "^[a-z][a-z0-9_]{0,39}$"
                              },
                              "label": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 80
                              },
                              "type": {
                                "type": "string",
                                "enum": ["boolean", "string", "integer", "number"]
                              },
                              "description": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 500
                              },
                              "enum": {
                                "minItems": 1,
                                "maxItems": 20,
                                "type": "array",
                                "items": {
                                  "type": "string",
                                  "maxLength": 80
                                }
                              }
                            },
                            "required": ["id", "label", "type", "description"],
                            "additionalProperties": false
                          }
                        },
                        "successCriterion": {
                          "anyOf": [
                            {
                              "type": "object",
                              "properties": {
                                "all": {
                                  "minItems": 1,
                                  "maxItems": 20,
                                  "type": "array",
                                  "items": {
                                    "anyOf": [
                                      {
                                        "type": "object",
                                        "properties": {
                                          "field": {
                                            "type": "string",
                                            "pattern": "^[a-z][a-z0-9_]{0,39}$"
                                          },
                                          "op": {
                                            "type": "string",
                                            "enum": [
                                              "eq",
                                              "neq",
                                              "contains",
                                              "not_contains",
                                              "gt",
                                              "gte",
                                              "lt",
                                              "lte",
                                              "in",
                                              "exists",
                                              "not_exists"
                                            ]
                                          },
                                          "value": {
                                            "anyOf": [
                                              {
                                                "anyOf": [
                                                  {
                                                    "type": "string",
                                                    "maxLength": 500
                                                  },
                                                  {
                                                    "type": "number"
                                                  },
                                                  {
                                                    "type": "boolean"
                                                  }
                                                ]
                                              },
                                              {
                                                "maxItems": 50,
                                                "type": "array",
                                                "items": {
                                                  "anyOf": [
                                                    {
                                                      "type": "string",
                                                      "maxLength": 500
                                                    },
                                                    {
                                                      "type": "number"
                                                    },
                                                    {
                                                      "type": "boolean"
                                                    }
                                                  ]
                                                }
                                              }
                                            ]
                                          }
                                        },
                                        "required": ["field", "op"],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "event": {
                                            "type": "string",
                                            "pattern": "^[a-z][a-z0-9_]{0,63}$"
                                          }
                                        },
                                        "required": ["event"],
                                        "additionalProperties": false
                                      }
                                    ]
                                  }
                                }
                              },
                              "required": ["all"],
                              "additionalProperties": false
                            },
                            {
                              "type": "object",
                              "properties": {
                                "any": {
                                  "minItems": 1,
                                  "maxItems": 20,
                                  "type": "array",
                                  "items": {
                                    "anyOf": [
                                      {
                                        "type": "object",
                                        "properties": {
                                          "field": {
                                            "type": "string",
                                            "pattern": "^[a-z][a-z0-9_]{0,39}$"
                                          },
                                          "op": {
                                            "type": "string",
                                            "enum": [
                                              "eq",
                                              "neq",
                                              "contains",
                                              "not_contains",
                                              "gt",
                                              "gte",
                                              "lt",
                                              "lte",
                                              "in",
                                              "exists",
                                              "not_exists"
                                            ]
                                          },
                                          "value": {
                                            "anyOf": [
                                              {
                                                "anyOf": [
                                                  {
                                                    "type": "string",
                                                    "maxLength": 500
                                                  },
                                                  {
                                                    "type": "number"
                                                  },
                                                  {
                                                    "type": "boolean"
                                                  }
                                                ]
                                              },
                                              {
                                                "maxItems": 50,
                                                "type": "array",
                                                "items": {
                                                  "anyOf": [
                                                    {
                                                      "type": "string",
                                                      "maxLength": 500
                                                    },
                                                    {
                                                      "type": "number"
                                                    },
                                                    {
                                                      "type": "boolean"
                                                    }
                                                  ]
                                                }
                                              }
                                            ]
                                          }
                                        },
                                        "required": ["field", "op"],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "event": {
                                            "type": "string",
                                            "pattern": "^[a-z][a-z0-9_]{0,63}$"
                                          }
                                        },
                                        "required": ["event"],
                                        "additionalProperties": false
                                      }
                                    ]
                                  }
                                }
                              },
                              "required": ["any"],
                              "additionalProperties": false
                            }
                          ]
                        },
                        "transferRules": {
                          "default": [],
                          "maxItems": 10,
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string",
                                "pattern": "^[a-z][a-z0-9_]{0,39}$"
                              },
                              "name": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 80
                              },
                              "when": {
                                "anyOf": [
                                  {
                                    "type": "object",
                                    "properties": {
                                      "all": {
                                        "minItems": 1,
                                        "maxItems": 20,
                                        "type": "array",
                                        "items": {
                                          "anyOf": [
                                            {
                                              "type": "object",
                                              "properties": {
                                                "field": {
                                                  "type": "string",
                                                  "pattern": "^[a-z][a-z0-9_]{0,39}$"
                                                },
                                                "op": {
                                                  "type": "string",
                                                  "enum": [
                                                    "eq",
                                                    "neq",
                                                    "contains",
                                                    "not_contains",
                                                    "gt",
                                                    "gte",
                                                    "lt",
                                                    "lte",
                                                    "in",
                                                    "exists",
                                                    "not_exists"
                                                  ]
                                                },
                                                "value": {
                                                  "anyOf": [
                                                    {
                                                      "anyOf": [
                                                        {
                                                          "type": "string",
                                                          "maxLength": 500
                                                        },
                                                        {
                                                          "type": "number"
                                                        },
                                                        {
                                                          "type": "boolean"
                                                        }
                                                      ]
                                                    },
                                                    {
                                                      "maxItems": 50,
                                                      "type": "array",
                                                      "items": {
                                                        "anyOf": [
                                                          {
                                                            "type": "string",
                                                            "maxLength": 500
                                                          },
                                                          {
                                                            "type": "number"
                                                          },
                                                          {
                                                            "type": "boolean"
                                                          }
                                                        ]
                                                      }
                                                    }
                                                  ]
                                                }
                                              },
                                              "required": ["field", "op"],
                                              "additionalProperties": false
                                            },
                                            {
                                              "type": "object",
                                              "properties": {
                                                "event": {
                                                  "type": "string",
                                                  "pattern": "^[a-z][a-z0-9_]{0,63}$"
                                                }
                                              },
                                              "required": ["event"],
                                              "additionalProperties": false
                                            }
                                          ]
                                        }
                                      }
                                    },
                                    "required": ["all"],
                                    "additionalProperties": false
                                  },
                                  {
                                    "type": "object",
                                    "properties": {
                                      "any": {
                                        "minItems": 1,
                                        "maxItems": 20,
                                        "type": "array",
                                        "items": {
                                          "anyOf": [
                                            {
                                              "type": "object",
                                              "properties": {
                                                "field": {
                                                  "type": "string",
                                                  "pattern": "^[a-z][a-z0-9_]{0,39}$"
                                                },
                                                "op": {
                                                  "type": "string",
                                                  "enum": [
                                                    "eq",
                                                    "neq",
                                                    "contains",
                                                    "not_contains",
                                                    "gt",
                                                    "gte",
                                                    "lt",
                                                    "lte",
                                                    "in",
                                                    "exists",
                                                    "not_exists"
                                                  ]
                                                },
                                                "value": {
                                                  "anyOf": [
                                                    {
                                                      "anyOf": [
                                                        {
                                                          "type": "string",
                                                          "maxLength": 500
                                                        },
                                                        {
                                                          "type": "number"
                                                        },
                                                        {
                                                          "type": "boolean"
                                                        }
                                                      ]
                                                    },
                                                    {
                                                      "maxItems": 50,
                                                      "type": "array",
                                                      "items": {
                                                        "anyOf": [
                                                          {
                                                            "type": "string",
                                                            "maxLength": 500
                                                          },
                                                          {
                                                            "type": "number"
                                                          },
                                                          {
                                                            "type": "boolean"
                                                          }
                                                        ]
                                                      }
                                                    }
                                                  ]
                                                }
                                              },
                                              "required": ["field", "op"],
                                              "additionalProperties": false
                                            },
                                            {
                                              "type": "object",
                                              "properties": {
                                                "event": {
                                                  "type": "string",
                                                  "pattern": "^[a-z][a-z0-9_]{0,63}$"
                                                }
                                              },
                                              "required": ["event"],
                                              "additionalProperties": false
                                            }
                                          ]
                                        }
                                      }
                                    },
                                    "required": ["any"],
                                    "additionalProperties": false
                                  }
                                ]
                              },
                              "to": {
                                "type": "string",
                                "pattern": "^\\+[1-9]\\d{6,14}$"
                              },
                              "whisper": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 500
                              },
                              "handoffLine": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 200
                              },
                              "hours": {
                                "type": "object",
                                "properties": {
                                  "windows": {
                                    "type": "object",
                                    "properties": {
                                      "sun": {
                                        "maxItems": 4,
                                        "type": "array",
                                        "items": {
                                          "type": "array",
                                          "prefixItems": [
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            },
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            }
                                          ]
                                        }
                                      },
                                      "mon": {
                                        "maxItems": 4,
                                        "type": "array",
                                        "items": {
                                          "type": "array",
                                          "prefixItems": [
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            },
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            }
                                          ]
                                        }
                                      },
                                      "tue": {
                                        "maxItems": 4,
                                        "type": "array",
                                        "items": {
                                          "type": "array",
                                          "prefixItems": [
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            },
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            }
                                          ]
                                        }
                                      },
                                      "wed": {
                                        "maxItems": 4,
                                        "type": "array",
                                        "items": {
                                          "type": "array",
                                          "prefixItems": [
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            },
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            }
                                          ]
                                        }
                                      },
                                      "thu": {
                                        "maxItems": 4,
                                        "type": "array",
                                        "items": {
                                          "type": "array",
                                          "prefixItems": [
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            },
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            }
                                          ]
                                        }
                                      },
                                      "fri": {
                                        "maxItems": 4,
                                        "type": "array",
                                        "items": {
                                          "type": "array",
                                          "prefixItems": [
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            },
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            }
                                          ]
                                        }
                                      },
                                      "sat": {
                                        "maxItems": 4,
                                        "type": "array",
                                        "items": {
                                          "type": "array",
                                          "prefixItems": [
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            },
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            }
                                          ]
                                        }
                                      }
                                    },
                                    "additionalProperties": false
                                  },
                                  "timezone": {
                                    "type": "string",
                                    "minLength": 1,
                                    "maxLength": 64
                                  }
                                },
                                "required": ["windows", "timezone"],
                                "additionalProperties": false
                              },
                              "fallback": {
                                "default": "callback",
                                "type": "string",
                                "enum": ["callback", "end"]
                              }
                            },
                            "required": [
                              "id",
                              "name",
                              "when",
                              "to",
                              "whisper",
                              "handoffLine",
                              "fallback"
                            ],
                            "additionalProperties": false
                          }
                        }
                      },
                      "required": [
                        "brief",
                        "purposeLine",
                        "schedule",
                        "pacing",
                        "retry",
                        "dataFields",
                        "transferRules"
                      ],
                      "additionalProperties": false
                    },
                    "requiredVariables": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "settingsConfirmedBy": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "pausedReason": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "createdBy": {
                      "type": "string"
                    },
                    "launchedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "completedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "createdAt": {
                      "type": "string"
                    },
                    "updatedAt": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "id",
                    "orgId",
                    "name",
                    "purpose",
                    "status",
                    "alwaysOn",
                    "priority",
                    "inboxId",
                    "settings",
                    "requiredVariables",
                    "settingsConfirmedBy",
                    "pausedReason",
                    "createdBy",
                    "launchedAt",
                    "completedAt",
                    "createdAt",
                    "updatedAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/outbound/campaigns/{id}/archive": {
      "post": {
        "operationId": "outbound-campaigns-archive",
        "summary": "Archive a campaign and retire its variants",
        "tags": ["Outbound"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 128
            },
            "required": true
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  }
                },
                "required": ["orgId"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 128
                    },
                    "orgId": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "purpose": {
                      "type": "string",
                      "enum": ["marketing", "lead_followup", "service"]
                    },
                    "status": {
                      "type": "string",
                      "enum": ["draft", "launching", "running", "paused", "completed", "archived"]
                    },
                    "alwaysOn": {
                      "type": "boolean"
                    },
                    "priority": {
                      "type": "number"
                    },
                    "inboxId": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 128
                    },
                    "settings": {
                      "type": "object",
                      "properties": {
                        "brief": {
                          "default": "",
                          "type": "string",
                          "maxLength": 4000
                        },
                        "purposeLine": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 200
                        },
                        "addressOrFreephone": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 200
                        },
                        "schedule": {
                          "default": {},
                          "type": "object",
                          "properties": {
                            "startAt": {
                              "type": "string",
                              "format": "date-time",
                              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                            },
                            "endAt": {
                              "type": "string",
                              "format": "date-time",
                              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                            },
                            "windows": {
                              "type": "object",
                              "properties": {
                                "sun": {
                                  "maxItems": 4,
                                  "type": "array",
                                  "items": {
                                    "type": "array",
                                    "prefixItems": [
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      },
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      }
                                    ]
                                  }
                                },
                                "mon": {
                                  "maxItems": 4,
                                  "type": "array",
                                  "items": {
                                    "type": "array",
                                    "prefixItems": [
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      },
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      }
                                    ]
                                  }
                                },
                                "tue": {
                                  "maxItems": 4,
                                  "type": "array",
                                  "items": {
                                    "type": "array",
                                    "prefixItems": [
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      },
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      }
                                    ]
                                  }
                                },
                                "wed": {
                                  "maxItems": 4,
                                  "type": "array",
                                  "items": {
                                    "type": "array",
                                    "prefixItems": [
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      },
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      }
                                    ]
                                  }
                                },
                                "thu": {
                                  "maxItems": 4,
                                  "type": "array",
                                  "items": {
                                    "type": "array",
                                    "prefixItems": [
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      },
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      }
                                    ]
                                  }
                                },
                                "fri": {
                                  "maxItems": 4,
                                  "type": "array",
                                  "items": {
                                    "type": "array",
                                    "prefixItems": [
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      },
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      }
                                    ]
                                  }
                                },
                                "sat": {
                                  "maxItems": 4,
                                  "type": "array",
                                  "items": {
                                    "type": "array",
                                    "prefixItems": [
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      },
                                      {
                                        "type": "string",
                                        "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                      }
                                    ]
                                  }
                                }
                              },
                              "additionalProperties": false
                            }
                          },
                          "additionalProperties": false
                        },
                        "pacing": {
                          "default": {
                            "maxConcurrent": 2,
                            "maxPerHour": 60,
                            "maxNewNumbersPerHour": 30
                          },
                          "type": "object",
                          "properties": {
                            "maxConcurrent": {
                              "default": 2,
                              "type": "integer",
                              "minimum": 1,
                              "maximum": 50
                            },
                            "maxPerHour": {
                              "default": 60,
                              "type": "integer",
                              "minimum": 1,
                              "maximum": 5000
                            },
                            "maxNewNumbersPerHour": {
                              "default": 30,
                              "type": "integer",
                              "minimum": 1,
                              "maximum": 1000
                            }
                          },
                          "required": ["maxConcurrent", "maxPerHour", "maxNewNumbersPerHour"],
                          "additionalProperties": false
                        },
                        "retry": {
                          "default": {
                            "maxAttempts": 3,
                            "retryOn": ["no_answer", "busy", "voicemail"],
                            "gapMinutes": 240
                          },
                          "type": "object",
                          "properties": {
                            "maxAttempts": {
                              "default": 3,
                              "type": "integer",
                              "minimum": 1,
                              "maximum": 3
                            },
                            "retryOn": {
                              "default": ["no_answer", "busy", "voicemail"],
                              "maxItems": 10,
                              "type": "array",
                              "items": {
                                "type": "string",
                                "enum": [
                                  "human",
                                  "voicemail",
                                  "fax",
                                  "no_answer",
                                  "busy",
                                  "failed",
                                  "canceled",
                                  "transferred",
                                  "opted_out",
                                  "abandoned"
                                ]
                              }
                            },
                            "gapMinutes": {
                              "default": 240,
                              "type": "integer",
                              "minimum": 240,
                              "maximum": 10080
                            }
                          },
                          "required": ["maxAttempts", "retryOn", "gapMinutes"],
                          "additionalProperties": false
                        },
                        "dataFields": {
                          "default": [],
                          "maxItems": 20,
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string",
                                "pattern": "^[a-z][a-z0-9_]{0,39}$"
                              },
                              "label": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 80
                              },
                              "type": {
                                "type": "string",
                                "enum": ["boolean", "string", "integer", "number"]
                              },
                              "description": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 500
                              },
                              "enum": {
                                "minItems": 1,
                                "maxItems": 20,
                                "type": "array",
                                "items": {
                                  "type": "string",
                                  "maxLength": 80
                                }
                              }
                            },
                            "required": ["id", "label", "type", "description"],
                            "additionalProperties": false
                          }
                        },
                        "successCriterion": {
                          "anyOf": [
                            {
                              "type": "object",
                              "properties": {
                                "all": {
                                  "minItems": 1,
                                  "maxItems": 20,
                                  "type": "array",
                                  "items": {
                                    "anyOf": [
                                      {
                                        "type": "object",
                                        "properties": {
                                          "field": {
                                            "type": "string",
                                            "pattern": "^[a-z][a-z0-9_]{0,39}$"
                                          },
                                          "op": {
                                            "type": "string",
                                            "enum": [
                                              "eq",
                                              "neq",
                                              "contains",
                                              "not_contains",
                                              "gt",
                                              "gte",
                                              "lt",
                                              "lte",
                                              "in",
                                              "exists",
                                              "not_exists"
                                            ]
                                          },
                                          "value": {
                                            "anyOf": [
                                              {
                                                "anyOf": [
                                                  {
                                                    "type": "string",
                                                    "maxLength": 500
                                                  },
                                                  {
                                                    "type": "number"
                                                  },
                                                  {
                                                    "type": "boolean"
                                                  }
                                                ]
                                              },
                                              {
                                                "maxItems": 50,
                                                "type": "array",
                                                "items": {
                                                  "anyOf": [
                                                    {
                                                      "type": "string",
                                                      "maxLength": 500
                                                    },
                                                    {
                                                      "type": "number"
                                                    },
                                                    {
                                                      "type": "boolean"
                                                    }
                                                  ]
                                                }
                                              }
                                            ]
                                          }
                                        },
                                        "required": ["field", "op"],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "event": {
                                            "type": "string",
                                            "pattern": "^[a-z][a-z0-9_]{0,63}$"
                                          }
                                        },
                                        "required": ["event"],
                                        "additionalProperties": false
                                      }
                                    ]
                                  }
                                }
                              },
                              "required": ["all"],
                              "additionalProperties": false
                            },
                            {
                              "type": "object",
                              "properties": {
                                "any": {
                                  "minItems": 1,
                                  "maxItems": 20,
                                  "type": "array",
                                  "items": {
                                    "anyOf": [
                                      {
                                        "type": "object",
                                        "properties": {
                                          "field": {
                                            "type": "string",
                                            "pattern": "^[a-z][a-z0-9_]{0,39}$"
                                          },
                                          "op": {
                                            "type": "string",
                                            "enum": [
                                              "eq",
                                              "neq",
                                              "contains",
                                              "not_contains",
                                              "gt",
                                              "gte",
                                              "lt",
                                              "lte",
                                              "in",
                                              "exists",
                                              "not_exists"
                                            ]
                                          },
                                          "value": {
                                            "anyOf": [
                                              {
                                                "anyOf": [
                                                  {
                                                    "type": "string",
                                                    "maxLength": 500
                                                  },
                                                  {
                                                    "type": "number"
                                                  },
                                                  {
                                                    "type": "boolean"
                                                  }
                                                ]
                                              },
                                              {
                                                "maxItems": 50,
                                                "type": "array",
                                                "items": {
                                                  "anyOf": [
                                                    {
                                                      "type": "string",
                                                      "maxLength": 500
                                                    },
                                                    {
                                                      "type": "number"
                                                    },
                                                    {
                                                      "type": "boolean"
                                                    }
                                                  ]
                                                }
                                              }
                                            ]
                                          }
                                        },
                                        "required": ["field", "op"],
                                        "additionalProperties": false
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "event": {
                                            "type": "string",
                                            "pattern": "^[a-z][a-z0-9_]{0,63}$"
                                          }
                                        },
                                        "required": ["event"],
                                        "additionalProperties": false
                                      }
                                    ]
                                  }
                                }
                              },
                              "required": ["any"],
                              "additionalProperties": false
                            }
                          ]
                        },
                        "transferRules": {
                          "default": [],
                          "maxItems": 10,
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string",
                                "pattern": "^[a-z][a-z0-9_]{0,39}$"
                              },
                              "name": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 80
                              },
                              "when": {
                                "anyOf": [
                                  {
                                    "type": "object",
                                    "properties": {
                                      "all": {
                                        "minItems": 1,
                                        "maxItems": 20,
                                        "type": "array",
                                        "items": {
                                          "anyOf": [
                                            {
                                              "type": "object",
                                              "properties": {
                                                "field": {
                                                  "type": "string",
                                                  "pattern": "^[a-z][a-z0-9_]{0,39}$"
                                                },
                                                "op": {
                                                  "type": "string",
                                                  "enum": [
                                                    "eq",
                                                    "neq",
                                                    "contains",
                                                    "not_contains",
                                                    "gt",
                                                    "gte",
                                                    "lt",
                                                    "lte",
                                                    "in",
                                                    "exists",
                                                    "not_exists"
                                                  ]
                                                },
                                                "value": {
                                                  "anyOf": [
                                                    {
                                                      "anyOf": [
                                                        {
                                                          "type": "string",
                                                          "maxLength": 500
                                                        },
                                                        {
                                                          "type": "number"
                                                        },
                                                        {
                                                          "type": "boolean"
                                                        }
                                                      ]
                                                    },
                                                    {
                                                      "maxItems": 50,
                                                      "type": "array",
                                                      "items": {
                                                        "anyOf": [
                                                          {
                                                            "type": "string",
                                                            "maxLength": 500
                                                          },
                                                          {
                                                            "type": "number"
                                                          },
                                                          {
                                                            "type": "boolean"
                                                          }
                                                        ]
                                                      }
                                                    }
                                                  ]
                                                }
                                              },
                                              "required": ["field", "op"],
                                              "additionalProperties": false
                                            },
                                            {
                                              "type": "object",
                                              "properties": {
                                                "event": {
                                                  "type": "string",
                                                  "pattern": "^[a-z][a-z0-9_]{0,63}$"
                                                }
                                              },
                                              "required": ["event"],
                                              "additionalProperties": false
                                            }
                                          ]
                                        }
                                      }
                                    },
                                    "required": ["all"],
                                    "additionalProperties": false
                                  },
                                  {
                                    "type": "object",
                                    "properties": {
                                      "any": {
                                        "minItems": 1,
                                        "maxItems": 20,
                                        "type": "array",
                                        "items": {
                                          "anyOf": [
                                            {
                                              "type": "object",
                                              "properties": {
                                                "field": {
                                                  "type": "string",
                                                  "pattern": "^[a-z][a-z0-9_]{0,39}$"
                                                },
                                                "op": {
                                                  "type": "string",
                                                  "enum": [
                                                    "eq",
                                                    "neq",
                                                    "contains",
                                                    "not_contains",
                                                    "gt",
                                                    "gte",
                                                    "lt",
                                                    "lte",
                                                    "in",
                                                    "exists",
                                                    "not_exists"
                                                  ]
                                                },
                                                "value": {
                                                  "anyOf": [
                                                    {
                                                      "anyOf": [
                                                        {
                                                          "type": "string",
                                                          "maxLength": 500
                                                        },
                                                        {
                                                          "type": "number"
                                                        },
                                                        {
                                                          "type": "boolean"
                                                        }
                                                      ]
                                                    },
                                                    {
                                                      "maxItems": 50,
                                                      "type": "array",
                                                      "items": {
                                                        "anyOf": [
                                                          {
                                                            "type": "string",
                                                            "maxLength": 500
                                                          },
                                                          {
                                                            "type": "number"
                                                          },
                                                          {
                                                            "type": "boolean"
                                                          }
                                                        ]
                                                      }
                                                    }
                                                  ]
                                                }
                                              },
                                              "required": ["field", "op"],
                                              "additionalProperties": false
                                            },
                                            {
                                              "type": "object",
                                              "properties": {
                                                "event": {
                                                  "type": "string",
                                                  "pattern": "^[a-z][a-z0-9_]{0,63}$"
                                                }
                                              },
                                              "required": ["event"],
                                              "additionalProperties": false
                                            }
                                          ]
                                        }
                                      }
                                    },
                                    "required": ["any"],
                                    "additionalProperties": false
                                  }
                                ]
                              },
                              "to": {
                                "type": "string",
                                "pattern": "^\\+[1-9]\\d{6,14}$"
                              },
                              "whisper": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 500
                              },
                              "handoffLine": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 200
                              },
                              "hours": {
                                "type": "object",
                                "properties": {
                                  "windows": {
                                    "type": "object",
                                    "properties": {
                                      "sun": {
                                        "maxItems": 4,
                                        "type": "array",
                                        "items": {
                                          "type": "array",
                                          "prefixItems": [
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            },
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            }
                                          ]
                                        }
                                      },
                                      "mon": {
                                        "maxItems": 4,
                                        "type": "array",
                                        "items": {
                                          "type": "array",
                                          "prefixItems": [
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            },
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            }
                                          ]
                                        }
                                      },
                                      "tue": {
                                        "maxItems": 4,
                                        "type": "array",
                                        "items": {
                                          "type": "array",
                                          "prefixItems": [
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            },
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            }
                                          ]
                                        }
                                      },
                                      "wed": {
                                        "maxItems": 4,
                                        "type": "array",
                                        "items": {
                                          "type": "array",
                                          "prefixItems": [
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            },
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            }
                                          ]
                                        }
                                      },
                                      "thu": {
                                        "maxItems": 4,
                                        "type": "array",
                                        "items": {
                                          "type": "array",
                                          "prefixItems": [
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            },
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            }
                                          ]
                                        }
                                      },
                                      "fri": {
                                        "maxItems": 4,
                                        "type": "array",
                                        "items": {
                                          "type": "array",
                                          "prefixItems": [
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            },
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            }
                                          ]
                                        }
                                      },
                                      "sat": {
                                        "maxItems": 4,
                                        "type": "array",
                                        "items": {
                                          "type": "array",
                                          "prefixItems": [
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            },
                                            {
                                              "type": "string",
                                              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                                            }
                                          ]
                                        }
                                      }
                                    },
                                    "additionalProperties": false
                                  },
                                  "timezone": {
                                    "type": "string",
                                    "minLength": 1,
                                    "maxLength": 64
                                  }
                                },
                                "required": ["windows", "timezone"],
                                "additionalProperties": false
                              },
                              "fallback": {
                                "default": "callback",
                                "type": "string",
                                "enum": ["callback", "end"]
                              }
                            },
                            "required": [
                              "id",
                              "name",
                              "when",
                              "to",
                              "whisper",
                              "handoffLine",
                              "fallback"
                            ],
                            "additionalProperties": false
                          }
                        }
                      },
                      "required": [
                        "brief",
                        "purposeLine",
                        "schedule",
                        "pacing",
                        "retry",
                        "dataFields",
                        "transferRules"
                      ],
                      "additionalProperties": false
                    },
                    "requiredVariables": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "settingsConfirmedBy": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "pausedReason": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "createdBy": {
                      "type": "string"
                    },
                    "launchedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "completedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "createdAt": {
                      "type": "string"
                    },
                    "updatedAt": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "id",
                    "orgId",
                    "name",
                    "purpose",
                    "status",
                    "alwaysOn",
                    "priority",
                    "inboxId",
                    "settings",
                    "requiredVariables",
                    "settingsConfirmedBy",
                    "pausedReason",
                    "createdBy",
                    "launchedAt",
                    "completedAt",
                    "createdAt",
                    "updatedAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/outbound/campaigns/{campaignId}/variants": {
      "post": {
        "operationId": "outbound-campaigns-variants-upsert",
        "summary": "Create a draft variant or update a paused variant weight",
        "tags": ["Outbound"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "campaignId",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 128
            },
            "required": true
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "key": {
                    "type": "string",
                    "enum": ["A", "B", "C"]
                  },
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 120
                  },
                  "weight": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 100
                  },
                  "baseAgentId": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 128
                  },
                  "overrides": {
                    "type": "object",
                    "properties": {
                      "greeting": {
                        "type": "string",
                        "maxLength": 500
                      },
                      "promptAppend": {
                        "type": "string",
                        "maxLength": 4000
                      },
                      "voiceId": {
                        "type": "string",
                        "maxLength": 100
                      }
                    },
                    "additionalProperties": false
                  }
                },
                "required": ["orgId", "key", "name", "weight", "baseAgentId", "overrides"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 128
                    },
                    "campaignId": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 128
                    },
                    "orgId": {
                      "type": "string"
                    },
                    "key": {
                      "type": "string",
                      "enum": ["A", "B", "C"]
                    },
                    "name": {
                      "type": "string"
                    },
                    "weight": {
                      "type": "number"
                    },
                    "baseAgentId": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 128
                    },
                    "overrides": {
                      "type": "object",
                      "properties": {
                        "greeting": {
                          "type": "string",
                          "maxLength": 500
                        },
                        "promptAppend": {
                          "type": "string",
                          "maxLength": 4000
                        },
                        "voiceId": {
                          "type": "string",
                          "maxLength": 100
                        }
                      },
                      "additionalProperties": false
                    },
                    "elevenLabsAgentId": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "elevenLabsWorkspace": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": ["platform", "byok"]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "snapshotHash": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "status": {
                      "type": "string",
                      "enum": ["draft", "active", "stopped", "retired"]
                    },
                    "retiredAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "createdAt": {
                      "type": "string"
                    },
                    "updatedAt": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "id",
                    "campaignId",
                    "orgId",
                    "key",
                    "name",
                    "weight",
                    "baseAgentId",
                    "overrides",
                    "elevenLabsAgentId",
                    "elevenLabsWorkspace",
                    "snapshotHash",
                    "status",
                    "retiredAt",
                    "createdAt",
                    "updatedAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/outbound/campaigns/{campaignId}/variants/{variantId}/stop": {
      "post": {
        "operationId": "outbound-campaigns-variants-stop",
        "summary": "Stop a campaign variant",
        "tags": ["Outbound"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "campaignId",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 128
            },
            "required": true
          },
          {
            "in": "path",
            "name": "variantId",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 128
            },
            "required": true
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  }
                },
                "required": ["orgId"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 128
                    },
                    "campaignId": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 128
                    },
                    "orgId": {
                      "type": "string"
                    },
                    "key": {
                      "type": "string",
                      "enum": ["A", "B", "C"]
                    },
                    "name": {
                      "type": "string"
                    },
                    "weight": {
                      "type": "number"
                    },
                    "baseAgentId": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 128
                    },
                    "overrides": {
                      "type": "object",
                      "properties": {
                        "greeting": {
                          "type": "string",
                          "maxLength": 500
                        },
                        "promptAppend": {
                          "type": "string",
                          "maxLength": 4000
                        },
                        "voiceId": {
                          "type": "string",
                          "maxLength": 100
                        }
                      },
                      "additionalProperties": false
                    },
                    "elevenLabsAgentId": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "elevenLabsWorkspace": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": ["platform", "byok"]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "snapshotHash": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "status": {
                      "type": "string",
                      "enum": ["draft", "active", "stopped", "retired"]
                    },
                    "retiredAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "createdAt": {
                      "type": "string"
                    },
                    "updatedAt": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "id",
                    "campaignId",
                    "orgId",
                    "key",
                    "name",
                    "weight",
                    "baseAgentId",
                    "overrides",
                    "elevenLabsAgentId",
                    "elevenLabsWorkspace",
                    "snapshotHash",
                    "status",
                    "retiredAt",
                    "createdAt",
                    "updatedAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/outbound/requests": {
      "post": {
        "operationId": "outbound-requests-add",
        "summary": "Queue calls with consent and policy validation",
        "tags": ["Outbound"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "campaignId": {
                    "type": "string"
                  },
                  "rows": {
                    "minItems": 1,
                    "maxItems": 1000,
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "phone": {
                          "type": "string"
                        },
                        "context": {},
                        "metadata": {},
                        "language": {
                          "type": "string"
                        },
                        "contactId": {
                          "type": "string"
                        },
                        "consent": {
                          "type": "object",
                          "properties": {
                            "sourceId": {
                              "type": "string"
                            },
                            "capturedAt": {
                              "type": "string"
                            },
                            "ipAddress": {
                              "type": "string"
                            },
                            "pageUrl": {
                              "type": "string"
                            },
                            "sourceRef": {
                              "type": "string"
                            }
                          },
                          "required": ["sourceId", "capturedAt"]
                        },
                        "idempotencyKey": {
                          "type": "string"
                        }
                      },
                      "required": ["phone"]
                    }
                  },
                  "source": {
                    "type": "string",
                    "enum": ["api", "import"]
                  }
                },
                "required": ["orgId", "campaignId", "rows"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "results": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "index": {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991
                          },
                          "ok": {
                            "type": "boolean"
                          },
                          "id": {
                            "type": "string"
                          },
                          "status": {
                            "type": "string",
                            "const": "queued"
                          },
                          "scheduledFor": {
                            "type": "string"
                          },
                          "variantKey": {
                            "type": "string",
                            "enum": ["A", "B", "C"]
                          },
                          "denyReason": {
                            "type": "string",
                            "enum": [
                              "capability_off",
                              "org_disabled",
                              "country_disabled",
                              "number_not_allowed",
                              "caller_id_mismatch",
                              "timezone_unknown",
                              "outside_window",
                              "holiday",
                              "no_consent",
                              "consent_insufficient",
                              "consent_expired",
                              "consent_source_unapproved",
                              "suppressed",
                              "opted_out_channel",
                              "attempt_limit",
                              "retry_gap",
                              "daily_cap",
                              "campaign_hourly_cap",
                              "concurrency_cap",
                              "insufficient_balance",
                              "campaign_not_running",
                              "already_active"
                            ]
                          },
                          "error": {
                            "type": "string"
                          }
                        },
                        "required": ["index", "ok"],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": ["results"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      },
      "get": {
        "operationId": "outbound-requests-list",
        "summary": "List call requests and their latest outcomes",
        "tags": ["Outbound"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "campaignId",
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "status",
            "schema": {
              "maxItems": 8,
              "type": "array",
              "items": {
                "type": "string",
                "enum": [
                  "queued",
                  "dialing",
                  "in_call",
                  "completed",
                  "skipped",
                  "canceled",
                  "exhausted",
                  "failed"
                ]
              }
            }
          },
          {
            "in": "query",
            "name": "updatedSince",
            "schema": {
              "type": "string",
              "format": "date-time",
              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
            }
          },
          {
            "in": "query",
            "name": "cursor",
            "schema": {
              "type": "string",
              "maxLength": 512
            }
          },
          {
            "in": "query",
            "name": "limit",
            "schema": {
              "default": 50,
              "type": "integer",
              "minimum": 1,
              "maximum": 100
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "requests": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "campaignId": {
                            "type": "string"
                          },
                          "variantId": {
                            "type": "string"
                          },
                          "contactId": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "conversationId": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "phoneE164": {
                            "type": "string"
                          },
                          "language": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "context": {
                            "type": "object",
                            "propertyNames": {
                              "type": "string"
                            },
                            "additionalProperties": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "number"
                                },
                                {
                                  "type": "boolean"
                                }
                              ]
                            }
                          },
                          "metadata": {
                            "type": "object",
                            "propertyNames": {
                              "type": "string"
                            },
                            "additionalProperties": {}
                          },
                          "priority": {
                            "type": "number"
                          },
                          "status": {
                            "type": "string",
                            "enum": [
                              "queued",
                              "dialing",
                              "in_call",
                              "completed",
                              "skipped",
                              "canceled",
                              "exhausted",
                              "failed"
                            ]
                          },
                          "attempts": {
                            "type": "number"
                          },
                          "nextAttemptAt": {
                            "type": "string"
                          },
                          "cancelRequested": {
                            "type": "boolean"
                          },
                          "lastOutcome": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "human",
                                  "voicemail",
                                  "fax",
                                  "no_answer",
                                  "busy",
                                  "failed",
                                  "canceled",
                                  "transferred",
                                  "opted_out",
                                  "abandoned"
                                ]
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "lastDenyReason": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "capability_off",
                                  "org_disabled",
                                  "country_disabled",
                                  "number_not_allowed",
                                  "caller_id_mismatch",
                                  "timezone_unknown",
                                  "outside_window",
                                  "holiday",
                                  "no_consent",
                                  "consent_insufficient",
                                  "consent_expired",
                                  "consent_source_unapproved",
                                  "suppressed",
                                  "opted_out_channel",
                                  "attempt_limit",
                                  "retry_gap",
                                  "daily_cap",
                                  "campaign_hourly_cap",
                                  "concurrency_cap",
                                  "insufficient_balance",
                                  "campaign_not_running",
                                  "already_active"
                                ]
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "result": {
                            "anyOf": [
                              {
                                "type": "object",
                                "propertyNames": {
                                  "type": "string"
                                },
                                "additionalProperties": {}
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "succeeded": {
                            "anyOf": [
                              {
                                "type": "boolean"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "source": {
                            "type": "string",
                            "enum": ["api", "import", "workflow", "test"]
                          },
                          "createdAt": {
                            "type": "string"
                          },
                          "updatedAt": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "id",
                          "campaignId",
                          "variantId",
                          "contactId",
                          "conversationId",
                          "phoneE164",
                          "language",
                          "context",
                          "metadata",
                          "priority",
                          "status",
                          "attempts",
                          "nextAttemptAt",
                          "cancelRequested",
                          "lastOutcome",
                          "lastDenyReason",
                          "result",
                          "succeeded",
                          "source",
                          "createdAt",
                          "updatedAt"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "nextCursor": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": ["requests", "nextCursor"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/outbound/requests/{id}": {
      "get": {
        "operationId": "outbound-requests-get",
        "summary": "Get a call request and its current outcome",
        "tags": ["Outbound"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "campaignId": {
                      "type": "string"
                    },
                    "variantId": {
                      "type": "string"
                    },
                    "contactId": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "conversationId": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "phoneE164": {
                      "type": "string"
                    },
                    "language": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "context": {
                      "type": "object",
                      "propertyNames": {
                        "type": "string"
                      },
                      "additionalProperties": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "number"
                          },
                          {
                            "type": "boolean"
                          }
                        ]
                      }
                    },
                    "metadata": {
                      "type": "object",
                      "propertyNames": {
                        "type": "string"
                      },
                      "additionalProperties": {}
                    },
                    "priority": {
                      "type": "number"
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "queued",
                        "dialing",
                        "in_call",
                        "completed",
                        "skipped",
                        "canceled",
                        "exhausted",
                        "failed"
                      ]
                    },
                    "attempts": {
                      "type": "number"
                    },
                    "nextAttemptAt": {
                      "type": "string"
                    },
                    "cancelRequested": {
                      "type": "boolean"
                    },
                    "lastOutcome": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "human",
                            "voicemail",
                            "fax",
                            "no_answer",
                            "busy",
                            "failed",
                            "canceled",
                            "transferred",
                            "opted_out",
                            "abandoned"
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "lastDenyReason": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "capability_off",
                            "org_disabled",
                            "country_disabled",
                            "number_not_allowed",
                            "caller_id_mismatch",
                            "timezone_unknown",
                            "outside_window",
                            "holiday",
                            "no_consent",
                            "consent_insufficient",
                            "consent_expired",
                            "consent_source_unapproved",
                            "suppressed",
                            "opted_out_channel",
                            "attempt_limit",
                            "retry_gap",
                            "daily_cap",
                            "campaign_hourly_cap",
                            "concurrency_cap",
                            "insufficient_balance",
                            "campaign_not_running",
                            "already_active"
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "result": {
                      "anyOf": [
                        {
                          "type": "object",
                          "propertyNames": {
                            "type": "string"
                          },
                          "additionalProperties": {}
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "succeeded": {
                      "anyOf": [
                        {
                          "type": "boolean"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "source": {
                      "type": "string",
                      "enum": ["api", "import", "workflow", "test"]
                    },
                    "createdAt": {
                      "type": "string"
                    },
                    "updatedAt": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "id",
                    "campaignId",
                    "variantId",
                    "contactId",
                    "conversationId",
                    "phoneE164",
                    "language",
                    "context",
                    "metadata",
                    "priority",
                    "status",
                    "attempts",
                    "nextAttemptAt",
                    "cancelRequested",
                    "lastOutcome",
                    "lastDenyReason",
                    "result",
                    "succeeded",
                    "source",
                    "createdAt",
                    "updatedAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/outbound/requests/{id}/cancel": {
      "post": {
        "operationId": "outbound-requests-cancel",
        "summary": "Cancel a queued request or request cancellation of a live call",
        "tags": ["Outbound"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  }
                },
                "required": ["orgId"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "campaignId": {
                      "type": "string"
                    },
                    "variantId": {
                      "type": "string"
                    },
                    "contactId": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "conversationId": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "phoneE164": {
                      "type": "string"
                    },
                    "language": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "context": {
                      "type": "object",
                      "propertyNames": {
                        "type": "string"
                      },
                      "additionalProperties": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "number"
                          },
                          {
                            "type": "boolean"
                          }
                        ]
                      }
                    },
                    "metadata": {
                      "type": "object",
                      "propertyNames": {
                        "type": "string"
                      },
                      "additionalProperties": {}
                    },
                    "priority": {
                      "type": "number"
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "queued",
                        "dialing",
                        "in_call",
                        "completed",
                        "skipped",
                        "canceled",
                        "exhausted",
                        "failed"
                      ]
                    },
                    "attempts": {
                      "type": "number"
                    },
                    "nextAttemptAt": {
                      "type": "string"
                    },
                    "cancelRequested": {
                      "type": "boolean"
                    },
                    "lastOutcome": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "human",
                            "voicemail",
                            "fax",
                            "no_answer",
                            "busy",
                            "failed",
                            "canceled",
                            "transferred",
                            "opted_out",
                            "abandoned"
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "lastDenyReason": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "capability_off",
                            "org_disabled",
                            "country_disabled",
                            "number_not_allowed",
                            "caller_id_mismatch",
                            "timezone_unknown",
                            "outside_window",
                            "holiday",
                            "no_consent",
                            "consent_insufficient",
                            "consent_expired",
                            "consent_source_unapproved",
                            "suppressed",
                            "opted_out_channel",
                            "attempt_limit",
                            "retry_gap",
                            "daily_cap",
                            "campaign_hourly_cap",
                            "concurrency_cap",
                            "insufficient_balance",
                            "campaign_not_running",
                            "already_active"
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "result": {
                      "anyOf": [
                        {
                          "type": "object",
                          "propertyNames": {
                            "type": "string"
                          },
                          "additionalProperties": {}
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "succeeded": {
                      "anyOf": [
                        {
                          "type": "boolean"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "source": {
                      "type": "string",
                      "enum": ["api", "import", "workflow", "test"]
                    },
                    "createdAt": {
                      "type": "string"
                    },
                    "updatedAt": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "id",
                    "campaignId",
                    "variantId",
                    "contactId",
                    "conversationId",
                    "phoneE164",
                    "language",
                    "context",
                    "metadata",
                    "priority",
                    "status",
                    "attempts",
                    "nextAttemptAt",
                    "cancelRequested",
                    "lastOutcome",
                    "lastDenyReason",
                    "result",
                    "succeeded",
                    "source",
                    "createdAt",
                    "updatedAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/outbound/requests/export": {
      "get": {
        "operationId": "outbound-requests-export",
        "summary": "Export a page of call results as formula-safe CSV",
        "tags": ["Outbound"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "campaignId",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "cursor",
            "schema": {
              "type": "string",
              "maxLength": 512
            }
          },
          {
            "in": "query",
            "name": "limit",
            "schema": {
              "default": 1000,
              "type": "integer",
              "minimum": 1,
              "maximum": 1000
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "csv": {
                      "type": "string"
                    },
                    "nextCursor": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": ["csv", "nextCursor"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/outbound/requests/{id}/outcome": {
      "post": {
        "operationId": "outbound-requests-setOutcome",
        "summary": "Override a request conversion outcome",
        "tags": ["Outbound"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "converted": {
                    "type": "boolean"
                  },
                  "value": {
                    "type": "number",
                    "minimum": 0
                  }
                },
                "required": ["orgId", "converted"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "succeeded": {
                      "type": "boolean"
                    }
                  },
                  "required": ["id", "succeeded"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/outbound/calls": {
      "get": {
        "operationId": "outbound-calls-list",
        "summary": "List outbound call activity and live state",
        "tags": ["Outbound"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "campaignId",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "live",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "in": "query",
            "name": "limit",
            "schema": {
              "default": 50,
              "type": "integer",
              "minimum": 1,
              "maximum": 100
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "calls": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "requestId": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "campaignId": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "conversationId": {
                            "type": "string"
                          },
                          "toNumber": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "fromNumber": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "status": {
                            "type": "string",
                            "enum": [
                              "queued",
                              "ringing",
                              "in_progress",
                              "completed",
                              "busy",
                              "no_answer",
                              "failed",
                              "canceled"
                            ]
                          },
                          "collected": {
                            "anyOf": [
                              {
                                "type": "object",
                                "propertyNames": {
                                  "type": "string"
                                },
                                "additionalProperties": {}
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "result": {
                            "anyOf": [
                              {
                                "type": "object",
                                "propertyNames": {
                                  "type": "string"
                                },
                                "additionalProperties": {}
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "transfer": {
                            "anyOf": [
                              {
                                "type": "object",
                                "properties": {
                                  "ruleId": {
                                    "type": "string"
                                  },
                                  "to": {
                                    "type": "string"
                                  },
                                  "status": {
                                    "type": "string",
                                    "enum": ["pending", "dialing", "connected", "failed"]
                                  },
                                  "requestedBy": {
                                    "type": "string",
                                    "enum": ["rule", "admin", "agent"]
                                  },
                                  "at": {
                                    "type": "string"
                                  }
                                },
                                "required": ["to", "status", "requestedBy", "at"],
                                "additionalProperties": false
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "durationSeconds": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "createdAt": {
                            "type": "string"
                          },
                          "endedAt": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "billedCents": {
                            "type": "number"
                          },
                          "billingShortfallCents": {
                            "type": "number"
                          },
                          "proof": {
                            "anyOf": [
                              {
                                "type": "object",
                                "properties": {
                                  "answerLatencyMs": {
                                    "type": "number"
                                  },
                                  "secretHeaderValidated": {
                                    "type": "boolean"
                                  },
                                  "transferDispatch": {
                                    "type": "string",
                                    "enum": ["rest", "redirect"]
                                  }
                                },
                                "additionalProperties": false
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        },
                        "required": [
                          "id",
                          "requestId",
                          "campaignId",
                          "conversationId",
                          "toNumber",
                          "fromNumber",
                          "status",
                          "collected",
                          "result",
                          "transfer",
                          "durationSeconds",
                          "createdAt",
                          "endedAt",
                          "billedCents",
                          "billingShortfallCents",
                          "proof"
                        ],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": ["calls"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/outbound/calls/{id}": {
      "get": {
        "operationId": "outbound-calls-get",
        "summary": "Read a call transcript and collected data",
        "tags": ["Outbound"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "requestId": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "campaignId": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "conversationId": {
                      "type": "string"
                    },
                    "toNumber": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "fromNumber": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "queued",
                        "ringing",
                        "in_progress",
                        "completed",
                        "busy",
                        "no_answer",
                        "failed",
                        "canceled"
                      ]
                    },
                    "collected": {
                      "anyOf": [
                        {
                          "type": "object",
                          "propertyNames": {
                            "type": "string"
                          },
                          "additionalProperties": {}
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "result": {
                      "anyOf": [
                        {
                          "type": "object",
                          "propertyNames": {
                            "type": "string"
                          },
                          "additionalProperties": {}
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "transfer": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "ruleId": {
                              "type": "string"
                            },
                            "to": {
                              "type": "string"
                            },
                            "status": {
                              "type": "string",
                              "enum": ["pending", "dialing", "connected", "failed"]
                            },
                            "requestedBy": {
                              "type": "string",
                              "enum": ["rule", "admin", "agent"]
                            },
                            "at": {
                              "type": "string"
                            }
                          },
                          "required": ["to", "status", "requestedBy", "at"],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "durationSeconds": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "createdAt": {
                      "type": "string"
                    },
                    "endedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "billedCents": {
                      "type": "number"
                    },
                    "billingShortfallCents": {
                      "type": "number"
                    },
                    "proof": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "answerLatencyMs": {
                              "type": "number"
                            },
                            "secretHeaderValidated": {
                              "type": "boolean"
                            },
                            "transferDispatch": {
                              "type": "string",
                              "enum": ["rest", "redirect"]
                            }
                          },
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "transcript": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "role": {
                            "type": "string"
                          },
                          "content": {
                            "type": "string"
                          },
                          "createdAt": {
                            "type": "string"
                          }
                        },
                        "required": ["id", "role", "content", "createdAt"],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": [
                    "id",
                    "requestId",
                    "campaignId",
                    "conversationId",
                    "toNumber",
                    "fromNumber",
                    "status",
                    "collected",
                    "result",
                    "transfer",
                    "durationSeconds",
                    "createdAt",
                    "endedAt",
                    "billedCents",
                    "billingShortfallCents",
                    "proof",
                    "transcript"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/outbound/calls/{id}/end": {
      "post": {
        "operationId": "outbound-calls-end",
        "summary": "End an outbound call",
        "tags": ["Outbound"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  }
                },
                "required": ["orgId"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "queued",
                        "ringing",
                        "in_progress",
                        "completed",
                        "busy",
                        "no_answer",
                        "failed",
                        "canceled"
                      ]
                    }
                  },
                  "required": ["id", "status"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/outbound/calls/{id}/transfer": {
      "post": {
        "operationId": "outbound-calls-transfer",
        "summary": "Transfer a live call to a configured human rule",
        "tags": ["Outbound"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "ruleId": {
                    "type": "string"
                  }
                },
                "required": ["orgId", "ruleId"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "queued",
                        "ringing",
                        "in_progress",
                        "completed",
                        "busy",
                        "no_answer",
                        "failed",
                        "canceled"
                      ]
                    },
                    "transfer": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "ruleId": {
                              "type": "string"
                            },
                            "to": {
                              "type": "string"
                            },
                            "status": {
                              "type": "string",
                              "enum": ["pending", "dialing", "connected", "failed"]
                            },
                            "requestedBy": {
                              "type": "string",
                              "enum": ["rule", "admin", "agent"]
                            },
                            "at": {
                              "type": "string"
                            }
                          },
                          "required": ["to", "status", "requestedBy", "at"],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": ["id", "status", "transfer"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/outbound/limits": {
      "get": {
        "operationId": "outbound-limits-get",
        "summary": "Current outbound limits, usage and review requests",
        "tags": ["Outbound"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "limits": {
                      "type": "object",
                      "properties": {
                        "concurrentCalls": {
                          "type": "number"
                        },
                        "callsPerDay": {
                          "type": "number"
                        },
                        "requestsPerCampaign": {
                          "type": "number"
                        },
                        "testNumbers": {
                          "type": "number"
                        }
                      },
                      "required": [
                        "concurrentCalls",
                        "callsPerDay",
                        "requestsPerCampaign",
                        "testNumbers"
                      ],
                      "additionalProperties": false
                    },
                    "ceilings": {
                      "type": "object",
                      "properties": {
                        "concurrentCalls": {
                          "type": "number"
                        },
                        "callsPerDay": {
                          "type": "number"
                        },
                        "requestsPerCampaign": {
                          "type": "number"
                        },
                        "testNumbers": {
                          "type": "number"
                        }
                      },
                      "required": [
                        "concurrentCalls",
                        "callsPerDay",
                        "requestsPerCampaign",
                        "testNumbers"
                      ],
                      "additionalProperties": false
                    },
                    "usage": {
                      "type": "object",
                      "properties": {
                        "concurrentCalls": {
                          "type": "number"
                        },
                        "callsPerDay": {
                          "type": "number"
                        },
                        "testNumbers": {
                          "type": "number"
                        },
                        "requestsPerCampaign": {
                          "type": "number"
                        }
                      },
                      "required": [
                        "concurrentCalls",
                        "callsPerDay",
                        "testNumbers",
                        "requestsPerCampaign"
                      ],
                      "additionalProperties": false
                    },
                    "requests": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "orgId": {
                            "type": "string"
                          },
                          "idempotencyKey": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "limitKey": {
                            "type": "string",
                            "enum": [
                              "concurrentCalls",
                              "callsPerDay",
                              "requestsPerCampaign",
                              "testNumbers"
                            ]
                          },
                          "currentValue": {
                            "type": "number"
                          },
                          "requestedValue": {
                            "type": "number"
                          },
                          "justification": {
                            "type": "string"
                          },
                          "status": {
                            "type": "string",
                            "enum": ["pending", "approved", "rejected", "canceled"]
                          },
                          "decidedValue": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "consentSampleChecked": {
                            "anyOf": [
                              {
                                "type": "boolean"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "reviewerId": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "reviewNote": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "createdBy": {
                            "type": "string"
                          },
                          "createdAt": {
                            "type": "string"
                          },
                          "decidedAt": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "appliedAt": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "notifiedAt": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        },
                        "required": [
                          "id",
                          "orgId",
                          "idempotencyKey",
                          "limitKey",
                          "currentValue",
                          "requestedValue",
                          "justification",
                          "status",
                          "decidedValue",
                          "consentSampleChecked",
                          "reviewerId",
                          "reviewNote",
                          "createdBy",
                          "createdAt",
                          "decidedAt",
                          "appliedAt",
                          "notifiedAt"
                        ],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": ["limits", "ceilings", "usage", "requests"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/outbound/limits/requests": {
      "post": {
        "operationId": "outbound-limits-requestIncrease",
        "summary": "Request a higher outbound limit",
        "tags": ["Outbound"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "limitKey": {
                    "type": "string",
                    "enum": ["concurrentCalls", "callsPerDay", "requestsPerCampaign", "testNumbers"]
                  },
                  "requestedValue": {
                    "type": "integer",
                    "exclusiveMinimum": 0,
                    "maximum": 9007199254740991
                  },
                  "justification": {
                    "type": "string",
                    "minLength": 10,
                    "maxLength": 2000
                  },
                  "idempotencyKey": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  }
                },
                "required": ["orgId", "limitKey", "requestedValue", "justification"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "orgId": {
                      "type": "string"
                    },
                    "idempotencyKey": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "limitKey": {
                      "type": "string",
                      "enum": [
                        "concurrentCalls",
                        "callsPerDay",
                        "requestsPerCampaign",
                        "testNumbers"
                      ]
                    },
                    "currentValue": {
                      "type": "number"
                    },
                    "requestedValue": {
                      "type": "number"
                    },
                    "justification": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string",
                      "enum": ["pending", "approved", "rejected", "canceled"]
                    },
                    "decidedValue": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "consentSampleChecked": {
                      "anyOf": [
                        {
                          "type": "boolean"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "reviewerId": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "reviewNote": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "createdBy": {
                      "type": "string"
                    },
                    "createdAt": {
                      "type": "string"
                    },
                    "decidedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "appliedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "notifiedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": [
                    "id",
                    "orgId",
                    "idempotencyKey",
                    "limitKey",
                    "currentValue",
                    "requestedValue",
                    "justification",
                    "status",
                    "decidedValue",
                    "consentSampleChecked",
                    "reviewerId",
                    "reviewNote",
                    "createdBy",
                    "createdAt",
                    "decidedAt",
                    "appliedAt",
                    "notifiedAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/outbound/limits/requests/{id}/cancel": {
      "post": {
        "operationId": "outbound-limits-cancelRequest",
        "summary": "Cancel a pending outbound limit request",
        "tags": ["Outbound"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  }
                },
                "required": ["orgId"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "orgId": {
                      "type": "string"
                    },
                    "idempotencyKey": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "limitKey": {
                      "type": "string",
                      "enum": [
                        "concurrentCalls",
                        "callsPerDay",
                        "requestsPerCampaign",
                        "testNumbers"
                      ]
                    },
                    "currentValue": {
                      "type": "number"
                    },
                    "requestedValue": {
                      "type": "number"
                    },
                    "justification": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string",
                      "enum": ["pending", "approved", "rejected", "canceled"]
                    },
                    "decidedValue": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "consentSampleChecked": {
                      "anyOf": [
                        {
                          "type": "boolean"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "reviewerId": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "reviewNote": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "createdBy": {
                      "type": "string"
                    },
                    "createdAt": {
                      "type": "string"
                    },
                    "decidedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "appliedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "notifiedAt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": [
                    "id",
                    "orgId",
                    "idempotencyKey",
                    "limitKey",
                    "currentValue",
                    "requestedValue",
                    "justification",
                    "status",
                    "decidedValue",
                    "consentSampleChecked",
                    "reviewerId",
                    "reviewNote",
                    "createdBy",
                    "createdAt",
                    "decidedAt",
                    "appliedAt",
                    "notifiedAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/outbound/test-numbers/start": {
      "post": {
        "operationId": "outbound-testNumbers-start",
        "summary": "Verify an owned test destination by voice code",
        "tags": ["Outbound"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "phone": {
                    "type": "string",
                    "minLength": 7,
                    "maxLength": 32
                  },
                  "inboxId": {
                    "type": "string"
                  },
                  "idempotencyKey": {
                    "type": "string",
                    "pattern": "^[A-Za-z0-9_-]{8,128}$"
                  }
                },
                "required": ["orgId", "phone", "inboxId", "idempotencyKey"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "replayed": {
                      "type": "boolean"
                    },
                    "delivery": {
                      "type": "string",
                      "enum": ["submitted", "unknown", "replayed"]
                    }
                  },
                  "required": ["id", "replayed", "delivery"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/outbound/test-numbers/confirm": {
      "post": {
        "operationId": "outbound-testNumbers-confirm",
        "summary": "Confirm a test destination code",
        "tags": ["Outbound"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "id": {
                    "type": "string"
                  },
                  "code": {
                    "type": "string",
                    "maxLength": 32
                  }
                },
                "required": ["orgId", "id", "code"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "expiresAt": {
                      "type": "string"
                    }
                  },
                  "required": ["id", "expiresAt"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/outbound/test-numbers": {
      "get": {
        "operationId": "outbound-testNumbers-list",
        "summary": "List verified and pending test destinations",
        "tags": ["Outbound"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "numbers": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "phoneE164": {
                            "type": "string"
                          },
                          "verifiedAt": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "expiresAt": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "codeExpiresAt": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        },
                        "required": ["id", "phoneE164", "verifiedAt", "expiresAt", "codeExpiresAt"],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": ["numbers"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/outbound/test-numbers/remove": {
      "post": {
        "operationId": "outbound-testNumbers-remove",
        "summary": "Remove a verified or pending test destination",
        "tags": ["Outbound"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "id": {
                    "type": "string"
                  }
                },
                "required": ["orgId", "id"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "removed": {
                      "type": "boolean",
                      "const": true
                    }
                  },
                  "required": ["removed"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/outbound/test-call": {
      "post": {
        "operationId": "outbound-testCall",
        "summary": "Queue a campaign snapshot call to a verified test destination",
        "tags": ["Outbound"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "campaignId": {
                    "type": "string"
                  },
                  "variantId": {
                    "type": "string"
                  },
                  "testNumberId": {
                    "type": "string"
                  },
                  "context": {},
                  "idempotencyKey": {
                    "type": "string",
                    "pattern": "^[A-Za-z0-9_-]{8,128}$"
                  }
                },
                "required": ["orgId", "campaignId", "variantId", "testNumberId", "idempotencyKey"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "replayed": {
                      "type": "boolean"
                    }
                  },
                  "required": ["id", "replayed"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/outbound/consent-sources": {
      "post": {
        "operationId": "outbound-consentSources-create",
        "summary": "Submit a consent source for review",
        "tags": ["Outbound"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "idempotencyKey": {
                    "type": "string",
                    "pattern": "^[A-Za-z0-9_-]{8,128}$"
                  },
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 120
                  },
                  "captureChannel": {
                    "type": "string",
                    "enum": ["web_form", "paper", "email", "phone", "in_person", "api"]
                  },
                  "disclosureText": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 4000
                  },
                  "url": {
                    "type": "string",
                    "maxLength": 2048
                  },
                  "sellerName": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 120
                  },
                  "answers": {
                    "type": "object",
                    "properties": {
                      "signedOrTicked": {
                        "type": "boolean"
                      },
                      "namesSellerAndAutomatedCalls": {
                        "type": "boolean"
                      },
                      "askedToBeCalled": {
                        "type": "boolean"
                      }
                    },
                    "required": [
                      "signedOrTicked",
                      "namesSellerAndAutomatedCalls",
                      "askedToBeCalled"
                    ],
                    "additionalProperties": false
                  }
                },
                "required": [
                  "orgId",
                  "idempotencyKey",
                  "name",
                  "captureChannel",
                  "disclosureText",
                  "sellerName",
                  "answers"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "captureChannel": {
                      "type": "string",
                      "enum": ["web_form", "paper", "email", "phone", "in_person", "api"]
                    },
                    "disclosureText": {
                      "type": "string"
                    },
                    "url": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "sellerName": {
                      "type": "string"
                    },
                    "answers": {
                      "type": "object",
                      "properties": {
                        "signedOrTicked": {
                          "type": "boolean"
                        },
                        "namesSellerAndAutomatedCalls": {
                          "type": "boolean"
                        },
                        "askedToBeCalled": {
                          "type": "boolean"
                        }
                      },
                      "required": [
                        "signedOrTicked",
                        "namesSellerAndAutomatedCalls",
                        "askedToBeCalled"
                      ],
                      "additionalProperties": false
                    },
                    "derivedBasis": {
                      "type": "string",
                      "enum": [
                        "express_written",
                        "express_recorded",
                        "inquiry_callback",
                        "existing_customer",
                        "transaction"
                      ]
                    },
                    "coversAutomatedCalls": {
                      "type": "boolean"
                    },
                    "status": {
                      "type": "string",
                      "enum": ["pending", "approved", "rejected"]
                    },
                    "reviewNote": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "createdAt": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "id",
                    "name",
                    "captureChannel",
                    "disclosureText",
                    "url",
                    "sellerName",
                    "answers",
                    "derivedBasis",
                    "coversAutomatedCalls",
                    "status",
                    "reviewNote",
                    "createdAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      },
      "get": {
        "operationId": "outbound-consentSources-list",
        "summary": "List consent sources",
        "tags": ["Outbound"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "status",
            "schema": {
              "type": "string",
              "enum": ["pending", "approved", "rejected"]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "sources": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "captureChannel": {
                            "type": "string",
                            "enum": ["web_form", "paper", "email", "phone", "in_person", "api"]
                          },
                          "disclosureText": {
                            "type": "string"
                          },
                          "url": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "sellerName": {
                            "type": "string"
                          },
                          "answers": {
                            "type": "object",
                            "properties": {
                              "signedOrTicked": {
                                "type": "boolean"
                              },
                              "namesSellerAndAutomatedCalls": {
                                "type": "boolean"
                              },
                              "askedToBeCalled": {
                                "type": "boolean"
                              }
                            },
                            "required": [
                              "signedOrTicked",
                              "namesSellerAndAutomatedCalls",
                              "askedToBeCalled"
                            ],
                            "additionalProperties": false
                          },
                          "derivedBasis": {
                            "type": "string",
                            "enum": [
                              "express_written",
                              "express_recorded",
                              "inquiry_callback",
                              "existing_customer",
                              "transaction"
                            ]
                          },
                          "coversAutomatedCalls": {
                            "type": "boolean"
                          },
                          "status": {
                            "type": "string",
                            "enum": ["pending", "approved", "rejected"]
                          },
                          "reviewNote": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "createdAt": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "id",
                          "name",
                          "captureChannel",
                          "disclosureText",
                          "url",
                          "sellerName",
                          "answers",
                          "derivedBasis",
                          "coversAutomatedCalls",
                          "status",
                          "reviewNote",
                          "createdAt"
                        ],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": ["sources"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/outbound/consent-sources/{id}": {
      "get": {
        "operationId": "outbound-consentSources-get",
        "summary": "Get a consent source",
        "tags": ["Outbound"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "captureChannel": {
                      "type": "string",
                      "enum": ["web_form", "paper", "email", "phone", "in_person", "api"]
                    },
                    "disclosureText": {
                      "type": "string"
                    },
                    "url": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "sellerName": {
                      "type": "string"
                    },
                    "answers": {
                      "type": "object",
                      "properties": {
                        "signedOrTicked": {
                          "type": "boolean"
                        },
                        "namesSellerAndAutomatedCalls": {
                          "type": "boolean"
                        },
                        "askedToBeCalled": {
                          "type": "boolean"
                        }
                      },
                      "required": [
                        "signedOrTicked",
                        "namesSellerAndAutomatedCalls",
                        "askedToBeCalled"
                      ],
                      "additionalProperties": false
                    },
                    "derivedBasis": {
                      "type": "string",
                      "enum": [
                        "express_written",
                        "express_recorded",
                        "inquiry_callback",
                        "existing_customer",
                        "transaction"
                      ]
                    },
                    "coversAutomatedCalls": {
                      "type": "boolean"
                    },
                    "status": {
                      "type": "string",
                      "enum": ["pending", "approved", "rejected"]
                    },
                    "reviewNote": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "createdAt": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "id",
                    "name",
                    "captureChannel",
                    "disclosureText",
                    "url",
                    "sellerName",
                    "answers",
                    "derivedBasis",
                    "coversAutomatedCalls",
                    "status",
                    "reviewNote",
                    "createdAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/outbound/consent-sources/{id}/submit": {
      "post": {
        "operationId": "outbound-consentSources-submit",
        "summary": "Submit an immutable consent source for review",
        "tags": ["Outbound"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "idempotencyKey": {
                    "type": "string",
                    "pattern": "^[A-Za-z0-9_-]{8,128}$"
                  }
                },
                "required": ["orgId", "idempotencyKey"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "captureChannel": {
                      "type": "string",
                      "enum": ["web_form", "paper", "email", "phone", "in_person", "api"]
                    },
                    "disclosureText": {
                      "type": "string"
                    },
                    "url": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "sellerName": {
                      "type": "string"
                    },
                    "answers": {
                      "type": "object",
                      "properties": {
                        "signedOrTicked": {
                          "type": "boolean"
                        },
                        "namesSellerAndAutomatedCalls": {
                          "type": "boolean"
                        },
                        "askedToBeCalled": {
                          "type": "boolean"
                        }
                      },
                      "required": [
                        "signedOrTicked",
                        "namesSellerAndAutomatedCalls",
                        "askedToBeCalled"
                      ],
                      "additionalProperties": false
                    },
                    "derivedBasis": {
                      "type": "string",
                      "enum": [
                        "express_written",
                        "express_recorded",
                        "inquiry_callback",
                        "existing_customer",
                        "transaction"
                      ]
                    },
                    "coversAutomatedCalls": {
                      "type": "boolean"
                    },
                    "status": {
                      "type": "string",
                      "enum": ["pending", "approved", "rejected"]
                    },
                    "reviewNote": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "createdAt": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "id",
                    "name",
                    "captureChannel",
                    "disclosureText",
                    "url",
                    "sellerName",
                    "answers",
                    "derivedBasis",
                    "coversAutomatedCalls",
                    "status",
                    "reviewNote",
                    "createdAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/outbound/consent": {
      "post": {
        "operationId": "outbound-consent-add",
        "summary": "Record consent evidence for phone numbers",
        "tags": ["Outbound"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "records": {
                    "minItems": 1,
                    "maxItems": 1000,
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "phone": {
                          "type": "string"
                        },
                        "sourceId": {
                          "type": "string"
                        },
                        "capturedAt": {
                          "type": "string"
                        },
                        "ipAddress": {
                          "type": "string"
                        },
                        "pageUrl": {
                          "type": "string"
                        },
                        "sourceRef": {
                          "type": "string"
                        },
                        "expiresAt": {
                          "type": "string"
                        },
                        "contactId": {
                          "type": "string"
                        }
                      },
                      "required": ["phone", "sourceId", "capturedAt"]
                    }
                  }
                },
                "required": ["orgId", "records"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "results": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "index": {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991
                          },
                          "ok": {
                            "type": "boolean"
                          },
                          "id": {
                            "type": "string"
                          },
                          "error": {
                            "type": "string"
                          }
                        },
                        "required": ["index", "ok"],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": ["results"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      },
      "get": {
        "operationId": "outbound-consent-list",
        "summary": "List consent records",
        "tags": ["Outbound"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "phone",
            "schema": {
              "type": "string",
              "maxLength": 64
            }
          },
          {
            "in": "query",
            "name": "sourceId",
            "schema": {
              "type": "string",
              "maxLength": 64
            }
          },
          {
            "in": "query",
            "name": "cursor",
            "schema": {
              "type": "string",
              "maxLength": 512
            }
          },
          {
            "in": "query",
            "name": "limit",
            "schema": {
              "default": 50,
              "type": "integer",
              "minimum": 1,
              "maximum": 100
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "records": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "sourceId": {
                            "type": "string"
                          },
                          "phone": {
                            "type": "string"
                          },
                          "contactId": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "capturedAt": {
                            "type": "string"
                          },
                          "ipAddress": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "pageUrl": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "sourceRef": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "expiresAt": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "createdAt": {
                            "type": "string"
                          },
                          "revokedAt": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "revokedReason": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        },
                        "required": [
                          "id",
                          "sourceId",
                          "phone",
                          "contactId",
                          "capturedAt",
                          "ipAddress",
                          "pageUrl",
                          "sourceRef",
                          "expiresAt",
                          "createdAt",
                          "revokedAt",
                          "revokedReason"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "nextCursor": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": ["records", "nextCursor"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/outbound/consent/revoke": {
      "post": {
        "operationId": "outbound-consent-revoke",
        "summary": "Revoke all consent records for a phone number",
        "tags": ["Outbound"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "phone": {
                    "type": "string",
                    "maxLength": 64
                  },
                  "reason": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  }
                },
                "required": ["orgId", "phone", "reason"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "revoked": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991
                    }
                  },
                  "required": ["revoked"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/outbound/suppression": {
      "post": {
        "operationId": "outbound-suppression-add",
        "summary": "Add phone numbers to the do-not-call list",
        "tags": ["Outbound"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "entries": {
                    "minItems": 1,
                    "maxItems": 1000,
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "phone": {
                          "type": "string"
                        },
                        "reason": {
                          "type": "string",
                          "enum": [
                            "opt_out_call",
                            "opt_out_other_channel",
                            "consent_disputed",
                            "wrong_number",
                            "manual",
                            "complaint"
                          ]
                        },
                        "note": {
                          "type": "string"
                        }
                      },
                      "required": ["phone", "reason"]
                    }
                  }
                },
                "required": ["orgId", "entries"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "results": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "index": {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991
                          },
                          "ok": {
                            "type": "boolean"
                          },
                          "id": {
                            "type": "string"
                          },
                          "error": {
                            "type": "string"
                          }
                        },
                        "required": ["index", "ok"],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": ["results"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      },
      "get": {
        "operationId": "outbound-suppression-list",
        "summary": "List the org's do-not-call numbers",
        "tags": ["Outbound"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "in": "query",
            "name": "orgId",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "search",
            "schema": {
              "type": "string",
              "maxLength": 32
            }
          },
          {
            "in": "query",
            "name": "cursor",
            "schema": {
              "type": "string",
              "maxLength": 512
            }
          },
          {
            "in": "query",
            "name": "limit",
            "schema": {
              "default": 50,
              "type": "integer",
              "minimum": 1,
              "maximum": 100
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "entries": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "phone": {
                            "type": "string"
                          },
                          "reason": {
                            "type": "string",
                            "enum": [
                              "opt_out_call",
                              "opt_out_other_channel",
                              "consent_disputed",
                              "wrong_number",
                              "manual",
                              "complaint",
                              "admin"
                            ]
                          },
                          "source": {
                            "type": "string"
                          },
                          "note": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "createdAt": {
                            "type": "string"
                          }
                        },
                        "required": ["id", "phone", "reason", "source", "note", "createdAt"],
                        "additionalProperties": false
                      }
                    },
                    "nextCursor": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": ["entries", "nextCursor"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.NOT_FOUND"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/outbound/suppression/remove": {
      "post": {
        "operationId": "outbound-suppression-remove",
        "summary": "Remove a phone number from the do-not-call list",
        "tags": ["Outbound"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "phone": {
                    "type": "string",
                    "maxLength": 64
                  },
                  "confirmPersonRequested": {
                    "type": "boolean"
                  },
                  "note": {
                    "type": "string",
                    "maxLength": 500
                  }
                },
                "required": ["orgId", "phone"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "removed": {
                      "type": "boolean",
                      "const": true
                    }
                  },
                  "required": ["removed"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    },
    "/api/rpc/events": {
      "post": {
        "operationId": "events-ingest",
        "summary": "Admit an idempotent booking or custom workflow event",
        "tags": ["Events"],
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "orgId": {
                    "type": "string"
                  },
                  "type": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": ["booking.created", "booking.updated", "booking.cancelled"]
                      },
                      {
                        "type": "string",
                        "pattern": "^custom\\.[a-z][a-z0-9_.-]{0,95}$"
                      }
                    ]
                  },
                  "occurredAt": {
                    "type": "string",
                    "format": "date-time",
                    "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
                  },
                  "idempotencyKey": {
                    "type": "string",
                    "minLength": 8,
                    "maxLength": 128,
                    "pattern": "^[a-zA-Z0-9_.:-]+$"
                  },
                  "subject": {
                    "type": "object",
                    "properties": {
                      "phone": {
                        "type": "string",
                        "pattern": "^\\+[1-9]\\d{6,14}$"
                      },
                      "name": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 120
                      },
                      "externalId": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 200
                      }
                    },
                    "required": ["phone", "externalId"],
                    "additionalProperties": false
                  },
                  "data": {
                    "type": "object",
                    "propertyNames": {
                      "type": "string"
                    },
                    "additionalProperties": {}
                  }
                },
                "required": ["orgId", "type", "occurredAt", "idempotencyKey", "subject", "data"],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "accepted": {
                      "type": "boolean",
                      "const": true
                    },
                    "eventId": {
                      "type": "string"
                    },
                    "replayed": {
                      "type": "boolean"
                    },
                    "queued": {
                      "type": "boolean"
                    }
                  },
                  "required": ["accepted", "eventId", "replayed", "queued"],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.BAD_REQUEST"
                }
              }
            }
          },
          "401": {
            "description": "Authorization not provided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.UNAUTHORIZED"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient access",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.FORBIDDEN"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/error.INTERNAL_SERVER_ERROR"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "error.UNAUTHORIZED": {
        "type": "object",
        "properties": {
          "message": {
            "type": "string",
            "description": "The error message",
            "example": "Authorization not provided"
          },
          "code": {
            "type": "string",
            "description": "The error code",
            "example": "UNAUTHORIZED"
          },
          "issues": {
            "description": "An array of issues that were responsible for the error",
            "example": [],
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "message": {
                  "type": "string"
                }
              },
              "required": ["message"],
              "additionalProperties": false
            }
          }
        },
        "required": ["message", "code"],
        "additionalProperties": false,
        "title": "Authorization not provided error (401)",
        "description": "The error information",
        "example": {
          "code": "UNAUTHORIZED",
          "message": "Authorization not provided",
          "issues": []
        }
      },
      "error.FORBIDDEN": {
        "type": "object",
        "properties": {
          "message": {
            "type": "string",
            "description": "The error message",
            "example": "Insufficient access"
          },
          "code": {
            "type": "string",
            "description": "The error code",
            "example": "FORBIDDEN"
          },
          "issues": {
            "description": "An array of issues that were responsible for the error",
            "example": [],
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "message": {
                  "type": "string"
                }
              },
              "required": ["message"],
              "additionalProperties": false
            }
          }
        },
        "required": ["message", "code"],
        "additionalProperties": false,
        "title": "Insufficient access error (403)",
        "description": "The error information",
        "example": {
          "code": "FORBIDDEN",
          "message": "Insufficient access",
          "issues": []
        }
      },
      "error.INTERNAL_SERVER_ERROR": {
        "type": "object",
        "properties": {
          "message": {
            "type": "string",
            "description": "The error message",
            "example": "Internal server error"
          },
          "code": {
            "type": "string",
            "description": "The error code",
            "example": "INTERNAL_SERVER_ERROR"
          },
          "issues": {
            "description": "An array of issues that were responsible for the error",
            "example": [],
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "message": {
                  "type": "string"
                }
              },
              "required": ["message"],
              "additionalProperties": false
            }
          }
        },
        "required": ["message", "code"],
        "additionalProperties": false,
        "title": "Internal server error error (500)",
        "description": "The error information",
        "example": {
          "code": "INTERNAL_SERVER_ERROR",
          "message": "Internal server error",
          "issues": []
        }
      },
      "error.BAD_REQUEST": {
        "type": "object",
        "properties": {
          "message": {
            "type": "string",
            "description": "The error message",
            "example": "Invalid input data"
          },
          "code": {
            "type": "string",
            "description": "The error code",
            "example": "BAD_REQUEST"
          },
          "issues": {
            "description": "An array of issues that were responsible for the error",
            "example": [],
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "message": {
                  "type": "string"
                }
              },
              "required": ["message"],
              "additionalProperties": false
            }
          }
        },
        "required": ["message", "code"],
        "additionalProperties": false,
        "title": "Invalid input data error (400)",
        "description": "The error information",
        "example": {
          "code": "BAD_REQUEST",
          "message": "Invalid input data",
          "issues": []
        }
      },
      "error.NOT_FOUND": {
        "type": "object",
        "properties": {
          "message": {
            "type": "string",
            "description": "The error message",
            "example": "Not found"
          },
          "code": {
            "type": "string",
            "description": "The error code",
            "example": "NOT_FOUND"
          },
          "issues": {
            "description": "An array of issues that were responsible for the error",
            "example": [],
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "message": {
                  "type": "string"
                }
              },
              "required": ["message"],
              "additionalProperties": false
            }
          }
        },
        "required": ["message", "code"],
        "additionalProperties": false,
        "title": "Not found error (404)",
        "description": "The error information",
        "example": {
          "code": "NOT_FOUND",
          "message": "Not found",
          "issues": []
        }
      }
    },
    "securitySchemes": {
      "Authorization": {
        "type": "http",
        "scheme": "bearer"
      },
      "OrganizationApiKey": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key",
        "description": "Organization-scoped API key. Only eligible org-scoped routes accept this principal; provide matching orgId."
      }
    }
  }
}
