{
  "openapi": "3.1.0",
  "info": {
    "title": "Leadlock Voice Agent SaaS API",
    "description": "Multi-tenant voice agent platform API.\n\n## Use Leadlock from Claude (MCP)\n\nAdd `https://mcp.leadlock.ai/mcp` as a custom connector in Claude (or ChatGPT, Cursor, Codex), sign in with your Leadlock account and approve. Step-by-step guide with screenshots: [docs.leadlock.ai/mcp](/mcp/).\n\n## Downloads\n\n- [OpenAPI spec (JSON)](/openapi-spec.json) for code generators, Postman and other tools.\n- [Full reference as Markdown](/llms-full.txt) to drop into an AI assistant.\n\n## LLM-friendly prose docs\n\nLooking for a single-page Markdown reference? [**llms-full.txt**](/llms-full.txt) (~300 KB) has every endpoint with descriptions, request/response shapes, all component schemas, and the Demo Customization Reference appendix. Designed for LLM context windows.\n\n## Authentication\n\nEvery endpoint accepts either `X-API-Key: <your_key>` or `Authorization: Bearer <your_key>`. Get a key from [app.leadlock.ai/dashboard/settings/api-keys](https://app.leadlock.ai/dashboard/settings/api-keys).\n\n## Demo customization\n\nThe `demo.config` object accepts well-known keys like `phone_caller_image`, `phone_accent_color`, `avatar_url`, `landing_heading`, and more. See the **Demo Customization Reference** section at the bottom of [llms-full.txt](/llms-full.txt) for the full per-channel inventory + copy-paste recipes (including the `?embed=true` flag for white-surround iframe embedding).",
    "version": "0.1.0"
  },
  "paths": {
    "/health": {
      "get": {
        "summary": "Health Check",
        "description": "Health check endpoint. Returns 503 during graceful shutdown drain.",
        "operationId": "health_check_health_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          }
        }
      }
    },
    "/health/deep": {
      "get": {
        "tags": [
          "Health"
        ],
        "summary": "Deep Health Check",
        "description": "Dependency-probing health check for the external uptime monitor.",
        "operationId": "deep_health_check_health_deep_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          }
        }
      }
    },
    "/account/delete-request": {
      "get": {
        "tags": [
          "Account",
          "account"
        ],
        "summary": "Get Deletion Request Status",
        "description": "Return the most recent deletion request status for this tenant, or null.",
        "operationId": "get_deletion_request_status_account_delete_request_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Account",
          "account"
        ],
        "summary": "Request Account Deletion",
        "description": "Submit a GDPR/CCPA account deletion request.\n\nOnly the account owner (not sub-account users) may request deletion.\nThe request is captured and Leadlock is notified; Leadlock processes within\nthe GDPR (1 month) / CCPA (45 days) SLA whichever is shorter.",
        "operationId": "request_account_deletion_account_delete_request_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DeletionRequestPayload"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/auth/signup": {
      "post": {
        "tags": [
          "Authentication"
        ],
        "summary": "Signup",
        "description": "Create a new user account.\n\nCreates:\n- Supabase Auth user\n- Tenant record (direct or agency)\n- User record with 'owner' role\n\nReturns tokens for immediate login.",
        "operationId": "signup_auth_signup_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SignupRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuthResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/auth/login": {
      "post": {
        "tags": [
          "Authentication"
        ],
        "summary": "Login",
        "description": "Login with email and password.\nReturns access token, refresh token, user, and tenant info.",
        "operationId": "login_auth_login_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LoginRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuthResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/auth/embed-sso": {
      "post": {
        "tags": [
          "Authentication"
        ],
        "summary": "Embed Sso",
        "description": "Embedded SSO \u2014 authenticate via partner platform iframe integration.\n\nAccepts an encrypted payload from the partner postMessage protocol,\ndecrypts it, maps the user to a Leadlock account, and returns\nJWT tokens for the session.\n\nPublic endpoint - no auth required (SSO replaces login).",
        "operationId": "embed_sso_auth_embed_sso_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EmbedSSORequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuthResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/auth/refresh": {
      "post": {
        "tags": [
          "Authentication"
        ],
        "summary": "Refresh",
        "description": "Refresh access token using refresh token.",
        "operationId": "refresh_auth_refresh_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RefreshTokenRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuthResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/auth/logout": {
      "post": {
        "tags": [
          "Authentication"
        ],
        "summary": "Logout",
        "description": "Logout user.\nClient should discard tokens. Server-side invalidation handled by Supabase.",
        "operationId": "logout_auth_logout_post",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          }
        }
      }
    },
    "/auth/me": {
      "get": {
        "tags": [
          "Authentication"
        ],
        "summary": "Get Me",
        "description": "Get current authenticated user and tenant info.\nRequires valid access token in Authorization header.",
        "operationId": "get_me_auth_me_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MeResponse"
                }
              }
            }
          }
        }
      }
    },
    "/auth/accept-invite": {
      "post": {
        "tags": [
          "Authentication"
        ],
        "summary": "Accept Invite",
        "description": "Accept a sub-account invitation.\n\nValidates token inline and creates auth account if valid.\nReturns tokens for immediate login.\nPublic endpoint - no auth required.\nRate limited: 5 attempts per hour per IP address.",
        "operationId": "accept_invite_auth_accept_invite_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AcceptInviteRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuthResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/auth/context": {
      "get": {
        "tags": [
          "Authentication"
        ],
        "summary": "Get Auth Context",
        "description": "Return tenant context for frontend navigation.\n\nReturns:\n- tenant_type: 'agency' | 'sub_account' | 'direct'\n- current_tenant_id: UUID\n- parent_tenant_id: UUID | None (for sub-accounts)\n- available_sub_accounts: list (for agencies only)",
        "operationId": "get_auth_context_auth_context_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "title": "Response Get Auth Context Auth Context Get"
                }
              }
            }
          }
        }
      }
    },
    "/auth/signup-pending": {
      "post": {
        "tags": [
          "Authentication"
        ],
        "summary": "Create Pending Signup",
        "description": "Create a pending signup record and redirect to Stripe checkout.\n\nPayment-First flow: Account is NOT created until Stripe payment succeeds.\nPassword is encrypted (not hashed) so it can be used to create the\nSupabase Auth user after payment.\n\nPublic endpoint - no auth required.\nRate limited by middleware: 5 requests per minute for /auth/* endpoints.",
        "operationId": "create_pending_signup_auth_signup_pending_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PendingSignupRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PendingSignupResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/auth/forgot-password": {
      "post": {
        "tags": [
          "Authentication"
        ],
        "summary": "Forgot Password",
        "description": "Send password reset email using Resend.\n\nGenerates a secure token, stores hash in DB, sends email via Resend.\nThis bypasses Supabase's email system for instant delivery.\n\nPublic endpoint - no auth required.",
        "operationId": "forgot_password_auth_forgot_password_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ForgotPasswordRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/auth/reset-password": {
      "post": {
        "tags": [
          "Authentication"
        ],
        "summary": "Reset Password",
        "description": "Reset password using our custom token.\n\nVerifies token from password_reset_tokens table, then updates\nthe user's password via Supabase admin API.\n\nPublic endpoint - no auth required.",
        "operationId": "reset_password_auth_reset_password_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ResetPasswordRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/auth/api-keys": {
      "get": {
        "tags": [
          "Authentication"
        ],
        "summary": "List Api Keys",
        "description": "List all API keys for the current tenant/sub-account (or the agency itself).",
        "operationId": "list_api_keys_auth_api_keys_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/APIKeyListResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      },
      "post": {
        "tags": [
          "Authentication"
        ],
        "summary": "Create Api Key",
        "description": "Create a new API key for webhook authentication.\n\nRequires owner or admin role. Requires a Starter, Agency or Pro plan.\nWith X-Sub-Account-Id, an agency user creates a key for that sub-account.\nWithout it, an agency OWNER creates an agency-scope key (DAN-467); admins\nand API keys cannot (see _refuse_agency_key_mint).\nThe plaintext key is only returned ONCE - store it securely!\n\nStarter, Agency and Pro keys all have the same unrestricted API access\n(DAN-177). Only PAYG is refused outright.",
        "operationId": "create_api_key_auth_api_keys_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/APIKeyCreate"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/APIKeyCreateResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/auth/api-keys/{key_id}": {
      "delete": {
        "tags": [
          "Authentication"
        ],
        "summary": "Delete Api Key",
        "description": "Delete an API key. Requires owner or admin role.",
        "operationId": "delete_api_key_auth_api_keys__key_id__delete",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "key_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Key Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/auth/api-keys/{key_id}/revoke": {
      "post": {
        "tags": [
          "Authentication"
        ],
        "summary": "Revoke Api Key",
        "description": "Revoke (deactivate) an API key without deleting it. Requires owner or admin role.",
        "operationId": "revoke_api_key_auth_api_keys__key_id__revoke_post",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "key_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Key Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/text-assistants": {
      "get": {
        "tags": [
          "Text Assistants",
          "Text Assistants"
        ],
        "summary": "List Text Assistants",
        "description": "List all text assistants for the current tenant.",
        "operationId": "list_text_assistants_text_assistants_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TextAssistantListResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      },
      "post": {
        "tags": [
          "Text Assistants",
          "Text Assistants"
        ],
        "summary": "Create Text Assistant",
        "description": "Create a new text assistant.",
        "operationId": "create_text_assistant_text_assistants_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TextAssistantCreate"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TextAssistantResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/text-assistants/{assistant_id}": {
      "get": {
        "tags": [
          "Text Assistants",
          "Text Assistants"
        ],
        "summary": "Get Text Assistant",
        "description": "Get a specific text assistant.",
        "operationId": "get_text_assistant_text_assistants__assistant_id__get",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "assistant_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Assistant Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TextAssistantResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "Text Assistants",
          "Text Assistants"
        ],
        "summary": "Update Text Assistant",
        "description": "Update a text assistant.\n\nExactly ``{\"is_active\": false}`` is the OFF switch and is open to every plan.\nAny other body (turning it on, any settings change, even an empty body)\nneeds the Text Assistant plan feature.",
        "operationId": "update_text_assistant_text_assistants__assistant_id__patch",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "assistant_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Assistant Id"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TextAssistantUpdate"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TextAssistantResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Text Assistants",
          "Text Assistants"
        ],
        "summary": "Delete Text Assistant",
        "description": "Delete a text assistant.",
        "operationId": "delete_text_assistant_text_assistants__assistant_id__delete",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "assistant_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Assistant Id"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Successful Response"
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/text-assistants/{assistant_id}/send": {
      "post": {
        "tags": [
          "Text Assistants",
          "Text Assistants"
        ],
        "summary": "Send Outbound Text",
        "description": "Send an outbound text message via this assistant.",
        "operationId": "send_outbound_text_text_assistants__assistant_id__send_post",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "assistant_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Assistant Id"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OutboundTextSendRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OutboundTextSendResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/text-assistants/{assistant_id}/tag-contact-count": {
      "get": {
        "tags": [
          "Text Assistants",
          "Text Assistants"
        ],
        "summary": "Get Tag Contact Count",
        "description": "Get the count of GHL contacts with this assistant's active tag.",
        "operationId": "get_tag_contact_count_text_assistants__assistant_id__tag_contact_count_get",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "assistant_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Assistant Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/text-assistants/{assistant_id}/toggle": {
      "post": {
        "tags": [
          "Text Assistants",
          "Text Assistants"
        ],
        "summary": "Toggle Text Assistant",
        "description": "Toggle text assistant active status.\n\nTurning it OFF is open to every plan. Turning it ON needs the Text Assistant\nplan feature, checked BEFORE the toggle so a denied request changes nothing.",
        "operationId": "toggle_text_assistant_text_assistants__assistant_id__toggle_post",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "assistant_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Assistant Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TextAssistantResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/text-followup/activity": {
      "get": {
        "tags": [
          "Text Follow-Up",
          "Text Follow-Up"
        ],
        "summary": "List Activity",
        "description": "List follow-up activity for the monitoring page.",
        "operationId": "list_activity_text_followup_activity_get",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "maximum": 200,
              "minimum": 1,
              "default": 50,
              "title": "Limit"
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0,
              "title": "Offset"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Status"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FollowUpActivityResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/text-followup/activity/{job_id}/cancel": {
      "post": {
        "tags": [
          "Text Follow-Up",
          "Text Follow-Up"
        ],
        "summary": "Cancel Job",
        "description": "Manually cancel a pending follow-up job.",
        "operationId": "cancel_job_text_followup_activity__job_id__cancel_post",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "job_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Job Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true,
                  "title": "Response Cancel Job Text Followup Activity  Job Id  Cancel Post"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/text-assistants/wizard/generate-knowledge": {
      "post": {
        "tags": [
          "Text Assistant Wizard",
          "Text Assistant Wizard"
        ],
        "summary": "Generate Knowledge",
        "description": "Generate AI suggestions for a specific knowledge section.\n\nThis endpoint uses xAI to generate content for one section at a time,\nallowing users to iterate on each section individually.\n\n**Sections:**\n- `services`: Products and services offered\n- `pricing`: Pricing information\n- `team`: Team members and roles\n- `faqs`: Common questions and answers",
        "operationId": "generate_knowledge_text_assistants_wizard_generate_knowledge_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/app__text_assistant__prompt_router__GenerateKnowledgeRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenerateKnowledgeResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/text-assistants/wizard/generate-all-knowledge": {
      "post": {
        "tags": [
          "Text Assistant Wizard",
          "Text Assistant Wizard"
        ],
        "summary": "Generate All Knowledge Endpoint",
        "description": "Generate all knowledge sections at once.\n\nThis is a convenience endpoint that generates services, pricing,\nteam, and FAQs in a single call. Takes longer but provides\neverything needed for the assistant prompt.",
        "operationId": "generate_all_knowledge_endpoint_text_assistants_wizard_generate_all_knowledge_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/app__text_assistant__prompt_router__GenerateAllKnowledgeRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenerateAllKnowledgeResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/text-assistants/wizard/enhance-description": {
      "post": {
        "tags": [
          "Text Assistant Wizard",
          "Text Assistant Wizard"
        ],
        "summary": "Enhance Description",
        "description": "Enhance a basic business description using AI.\n\nTakes a rough description and makes it more polished and professional\nwhile keeping it concise (under 50 words).",
        "operationId": "enhance_description_text_assistants_wizard_enhance_description_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EnhanceDescriptionRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EnhanceDescriptionResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/text-assistants/wizard/preview-prompt": {
      "post": {
        "tags": [
          "Text Assistant Wizard",
          "Text Assistant Wizard"
        ],
        "summary": "Preview Prompt",
        "description": "Preview the full generated prompt before creating the text assistant.\n\nThis builds the complete text assistant prompt from the provided\nknowledge sections and returns it along with recommended settings.",
        "operationId": "preview_prompt_text_assistants_wizard_preview_prompt_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TextPreviewPromptRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TextPreviewPromptResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/text-assistants/wizard/industry-presets": {
      "get": {
        "tags": [
          "Text Assistant Wizard",
          "Text Assistant Wizard"
        ],
        "summary": "Get Industry Presets",
        "description": "Get available industry presets.\n\nReturns a list of supported industries and their associated\nsuggestions for services and FAQs.",
        "operationId": "get_industry_presets_text_assistants_wizard_industry_presets_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IndustryPresetsResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/text-assistants/wizard/defaults": {
      "get": {
        "tags": [
          "Text Assistant Wizard",
          "Text Assistant Wizard"
        ],
        "summary": "Get Wizard Defaults",
        "description": "Get default settings for the text assistant wizard.\n\nReturns recommended settings for a text assistant.",
        "operationId": "get_wizard_defaults_text_assistants_wizard_defaults_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TextDefaultsResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/chat/conversations": {
      "get": {
        "tags": [
          "Chat",
          "Chat"
        ],
        "summary": "List Conversations",
        "description": "List text conversations with pagination and filters.",
        "operationId": "list_conversations_chat_conversations_get",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "maximum": 100,
              "minimum": 1,
              "default": 50,
              "title": "Limit"
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0,
              "title": "Offset"
            }
          },
          {
            "name": "channel",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Channel"
            }
          },
          {
            "name": "text_assistant_id",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "format": "uuid"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Text Assistant Id"
            }
          },
          {
            "name": "date_from",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Date From"
            }
          },
          {
            "name": "date_to",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Date To"
            }
          },
          {
            "name": "search",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Search"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TextConversationListResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/chat/conversations/{conversation_id}": {
      "get": {
        "tags": [
          "Chat",
          "Chat"
        ],
        "summary": "Get Conversation",
        "description": "Get a single conversation with assistant info.",
        "operationId": "get_conversation_chat_conversations__conversation_id__get",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "conversation_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Conversation Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TextConversationResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/chat/conversations/{conversation_id}/messages": {
      "get": {
        "tags": [
          "Chat",
          "Chat"
        ],
        "summary": "List Messages",
        "description": "List messages for a conversation, ordered oldest-first.",
        "operationId": "list_messages_chat_conversations__conversation_id__messages_get",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "conversation_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Conversation Id"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "maximum": 500,
              "minimum": 1,
              "default": 100,
              "title": "Limit"
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0,
              "title": "Offset"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TextMessageListResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/chat/stats": {
      "get": {
        "tags": [
          "Chat",
          "Chat"
        ],
        "summary": "Get Chat Stats",
        "description": "Get chat dashboard statistics.",
        "operationId": "get_chat_stats_chat_stats_get",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "date_from",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Date From"
            }
          },
          {
            "name": "date_to",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Date To"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChatStatsResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/webhooks/ghl/conversations": {
      "post": {
        "tags": [
          "Webhooks",
          "Webhooks"
        ],
        "summary": "Handle Ghl Message",
        "description": "Handle GHL InboundMessage webhooks.\n\nFlow:\n1. Verify webhook signature\n2. Find tenant by GHL location\n3. Check if AI should respond\n4. Add to debounce queue\n5. Return 200 immediately\n\nNote: Always return 200 to prevent GHL retries.",
        "operationId": "handle_ghl_message_webhooks_ghl_conversations_post",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": {
                    "type": "string"
                  },
                  "type": "object",
                  "title": "Response Handle Ghl Message Webhooks Ghl Conversations Post"
                }
              }
            }
          }
        }
      }
    },
    "/webhooks/ghl/conversations/human-takeover": {
      "post": {
        "tags": [
          "Webhooks",
          "Webhooks"
        ],
        "summary": "Handle Human Takeover",
        "description": "Handle OutboundMessage webhooks to detect human staff replies.\n\nWhen a human staff member sends a message, pause AI for that conversation.",
        "operationId": "handle_human_takeover_webhooks_ghl_conversations_human_takeover_post",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": {
                    "type": "string"
                  },
                  "type": "object",
                  "title": "Response Handle Human Takeover Webhooks Ghl Conversations Human Takeover Post"
                }
              }
            }
          }
        }
      }
    },
    "/webhooks/ghl/conversation-provider": {
      "post": {
        "tags": [
          "Webhooks",
          "Webhooks"
        ],
        "summary": "Handle Conversation Provider Outbound",
        "description": "Send a GHL-originated message out over the contact's Leadlock number.",
        "operationId": "handle_conversation_provider_outbound_webhooks_ghl_conversation_provider_post",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": {
                    "type": "string"
                  },
                  "type": "object",
                  "title": "Response Handle Conversation Provider Outbound Webhooks Ghl Conversation Provider Post"
                }
              }
            }
          }
        }
      }
    },
    "/webhooks/ghl/actions/outbound-call": {
      "post": {
        "tags": [
          "Webhooks",
          "Webhooks"
        ],
        "summary": "Action Outbound Call",
        "description": "Custom action leadlock_outbound_call: place an AI voice call to the contact.",
        "operationId": "action_outbound_call_webhooks_ghl_actions_outbound_call_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/GHLActionPayload"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "title": "Response Action Outbound Call Webhooks Ghl Actions Outbound Call Post"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/webhooks/ghl/actions/send-sms": {
      "post": {
        "tags": [
          "Webhooks",
          "Webhooks"
        ],
        "summary": "Action Send Sms",
        "description": "Custom action leadlock_send_sms: text the contact from the tenant's Leadlock number.",
        "operationId": "action_send_sms_webhooks_ghl_actions_send_sms_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/GHLActionPayload"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "title": "Response Action Send Sms Webhooks Ghl Actions Send Sms Post"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/tenants/me": {
      "get": {
        "tags": [
          "Tenants"
        ],
        "summary": "Get Current Tenant",
        "description": "Get current tenant details with usage stats.\n\nHot path: gates the dashboard shell on every cold load and sub-account\nswitch. Month call stats are aggregated DB-side via the get_call_stats\nRPC (never pulling call_logs rows into Python), and the independent\nqueries run in parallel. See AUDIT/full-audit-2026-07-14 snap track.",
        "operationId": "get_current_tenant_tenants_me_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TenantDetailResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      },
      "patch": {
        "tags": [
          "Tenants"
        ],
        "summary": "Update Tenant",
        "description": "Update current tenant settings.\n\nUses get_effective_tenant_id so agency owners editing a sub-account's\nsettings (webhook, etc.) write to the sub-account, not the parent.",
        "operationId": "update_tenant_tenants_me_patch",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TenantUpdate"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TenantResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/tenants/me/webhook": {
      "get": {
        "tags": [
          "Tenants"
        ],
        "summary": "Get Webhook Settings",
        "description": "Get webhook configuration for the effective tenant (sub-account aware).",
        "operationId": "get_webhook_settings_tenants_me_webhook_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookSettingsResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/tenants/me/webhook-test": {
      "post": {
        "tags": [
          "Tenants"
        ],
        "summary": "Test Webhook",
        "description": "Send a test payload to the configured webhook URL (sub-account aware).",
        "operationId": "test_webhook_tenants_me_webhook_test_post",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/agents/share-links": {
      "get": {
        "tags": [
          "Share Links"
        ],
        "summary": "List Share Links",
        "description": "List all active share links for the current tenant.",
        "operationId": "list_share_links_agents_share_links_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/ShareLinkSummary"
                  },
                  "type": "array",
                  "title": "Response List Share Links Agents Share Links Get"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/agents/{agent_id}/share": {
      "post": {
        "tags": [
          "Share Links"
        ],
        "summary": "Create Share Link",
        "description": "Create a public share link for an agent.",
        "operationId": "create_share_link_agents__agent_id__share_post",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "agent_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Agent Id"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateShareLinkRequest",
                "default": {}
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreateShareLinkResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "Share Links"
        ],
        "summary": "Get Share Link",
        "description": "Get the active share link for an agent.",
        "operationId": "get_share_link_agents__agent_id__share_get",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "agent_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Agent Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreateShareLinkResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Share Links"
        ],
        "summary": "Revoke Share Link",
        "description": "Revoke (deactivate) the share link for an agent.",
        "operationId": "revoke_share_link_agents__agent_id__share_delete",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "agent_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Agent Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/agents": {
      "get": {
        "tags": [
          "Agents"
        ],
        "summary": "List Agents",
        "description": "List all agents for the current tenant.\n\nFor agencies: requires sub-account context (X-Sub-Account-Id header).\nFor direct tenants: returns their agents.",
        "operationId": "list_agents_agents_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentListResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      },
      "post": {
        "tags": [
          "Agents"
        ],
        "summary": "Create Agent",
        "description": "Create a new agent.\n\nFor agencies: requires sub-account context (X-Sub-Account-Id header).\nFor direct tenants: creates agent under their tenant.\nChecks agent limit for the effective tenant.",
        "operationId": "create_agent_agents_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AgentCreate"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/agents/{agent_id}": {
      "get": {
        "tags": [
          "Agents"
        ],
        "summary": "Get Agent",
        "description": "Get a specific agent by ID.\n\nFor agencies: requires sub-account context (X-Sub-Account-Id header).\nFor direct tenants: returns their agent.",
        "operationId": "get_agent_agents__agent_id__get",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "agent_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Agent Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "Agents"
        ],
        "summary": "Update Agent",
        "description": "Update an agent.\n\nFor agencies: requires sub-account context (X-Sub-Account-Id header).\nFor direct tenants: updates their agent.",
        "operationId": "update_agent_agents__agent_id__patch",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "agent_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Agent Id"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AgentUpdate"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Agents"
        ],
        "summary": "Delete Agent",
        "description": "Delete an agent.\n\nFor agencies: requires sub-account context (X-Sub-Account-Id header).\nFor direct tenants: deletes their agent.\n\nRaises ValidationError if agent is linked to text assistants.",
        "operationId": "delete_agent_agents__agent_id__delete",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "agent_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Agent Id"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Successful Response"
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/agents/{agent_id}/deletion-impact": {
      "get": {
        "tags": [
          "Agents"
        ],
        "summary": "Get Agent Deletion Impact",
        "description": "Report what deleting this agent will affect, so the UI can confirm first.\n\nSequences that reference the agent will be paused (their agent_id is set to\nNULL) and must have an agent reassigned to resume. Linked text assistants\nare deleted. Returns the affected sequences by name plus the text-assistant\ncount so the delete dialog can warn the user before the destructive action.",
        "operationId": "get_agent_deletion_impact_agents__agent_id__deletion_impact_get",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "agent_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Agent Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/agents/{agent_id}/toggle": {
      "post": {
        "tags": [
          "Agents"
        ],
        "summary": "Toggle Agent",
        "description": "Toggle an agent's is_active status.\n\nFlips the current is_active value and returns the updated agent.",
        "operationId": "toggle_agent_agents__agent_id__toggle_post",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "agent_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Agent Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/agents/{agent_id}/inbound-webhook-test": {
      "post": {
        "tags": [
          "Agents"
        ],
        "summary": "Test Inbound Webhook",
        "description": "Send a sample call_inbound payload to the agent's configured URL; report result.\n\nScoped by both agent id AND tenant_id so a caller cannot test another\ntenant's agent. Re-validates the URL (SSRF) before firing.",
        "operationId": "test_inbound_webhook_agents__agent_id__inbound_webhook_test_post",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "agent_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Agent Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/agents/{agent_id}/duplicate": {
      "post": {
        "tags": [
          "Agents"
        ],
        "summary": "Duplicate Agent",
        "description": "Duplicate an agent within the same tenant.\n\nCreates a copy with \" (Copy)\" appended to name and is_active=False.\nElevenLabs agent is re-synced if applicable.",
        "operationId": "duplicate_agent_agents__agent_id__duplicate_post",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "agent_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Agent Id"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/agents/{agent_id}/copy-to/{target_tenant_id}": {
      "post": {
        "tags": [
          "Agents"
        ],
        "summary": "Copy Agent To Sub Account",
        "description": "Copy an agent to another sub-account (agency-only).\n\nVerifies the user's agency owns both source and target sub-accounts.\nClears tenant-specific fields (calendars, knowledge bases).",
        "operationId": "copy_agent_to_sub_account_agents__agent_id__copy_to__target_tenant_id__post",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "agent_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Agent Id"
            }
          },
          {
            "name": "target_tenant_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Target Tenant Id"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/agents/{agent_id}/phone-numbers": {
      "get": {
        "tags": [
          "Agents"
        ],
        "summary": "Get Agent Phone Numbers",
        "description": "Get phone numbers assigned to an agent.\n\nFor agencies: requires sub-account context (X-Sub-Account-Id header).\nFor direct tenants: returns phone numbers assigned to their agent.\n\nNote: Phone numbers may be owned by an agency (tenant_id = agency) but\nassigned to a sub-account (sub_account_id = sub_account). We need to\nhandle both cases.",
        "operationId": "get_agent_phone_numbers_agents__agent_id__phone_numbers_get",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "agent_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Agent Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/agents/test/chat": {
      "post": {
        "tags": [
          "Agents"
        ],
        "summary": "Test Agent Chat",
        "description": "Test agent in text mode.\n\nUses xAI Chat Completions API with same Grok model as voice testing.\n\nFor agencies: requires sub-account context (X-Sub-Account-Id header).\nFor direct tenants: tests their agent.",
        "operationId": "test_agent_chat_agents_test_chat_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TestChatRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TestChatResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/agents/test/voice": {
      "post": {
        "tags": [
          "Agents"
        ],
        "summary": "Test Agent Voice",
        "description": "Test agent in voice mode.\n\nUses xAI Realtime Voice API to process audio and return AI response.\n\nFor agencies: requires sub-account context (X-Sub-Account-Id header).\nFor direct tenants: tests their agent.",
        "operationId": "test_agent_voice_agents_test_voice_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TestVoiceRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TestVoiceResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/agents/{agent_id}/functions": {
      "get": {
        "tags": [
          "Custom Functions"
        ],
        "summary": "List Agent Functions",
        "description": "List functions attached to an agent plus available library functions.\n\nReturns two lists:\n- attached: Functions currently attached to this agent\n- available: Library functions not yet attached\n\nFor agencies: requires sub-account context (X-Sub-Account-Id header).",
        "operationId": "list_agent_functions_agents__agent_id__functions_get",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "agent_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Agent Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentFunctionsListResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Custom Functions"
        ],
        "summary": "Create Custom Function",
        "description": "Create a new custom function and attach it to this agent.\n\nBackward-compatible endpoint that creates in library and auto-attaches.\nFor agencies: requires sub-account context (X-Sub-Account-Id header).",
        "operationId": "create_custom_function_agents__agent_id__functions_post",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "agent_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Agent Id"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CustomFunctionCreate"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomFunctionResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/agents/{agent_id}/functions/attach": {
      "post": {
        "tags": [
          "Custom Functions"
        ],
        "summary": "Attach Function To Agent",
        "description": "Attach an existing library function to this agent.\n\nFor agencies: requires sub-account context (X-Sub-Account-Id header).",
        "operationId": "attach_function_to_agent_agents__agent_id__functions_attach_post",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "agent_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Agent Id"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AttachFunctionRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AttachFunctionResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/agents/{agent_id}/functions/detach/{function_id}": {
      "delete": {
        "tags": [
          "Custom Functions"
        ],
        "summary": "Detach Function From Agent",
        "description": "Detach a function from this agent.\n\nThe function remains in the library and can be re-attached later.\nFor agencies: requires sub-account context (X-Sub-Account-Id header).",
        "operationId": "detach_function_from_agent_agents__agent_id__functions_detach__function_id__delete",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "agent_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Agent Id"
            }
          },
          {
            "name": "function_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Function Id"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Successful Response"
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/agents/{agent_id}/functions/{function_id}/enable": {
      "post": {
        "tags": [
          "Custom Functions"
        ],
        "summary": "Enable Function For Agent",
        "description": "Enable a function for this agent.\n\nFor agencies: requires sub-account context (X-Sub-Account-Id header).",
        "operationId": "enable_function_for_agent_agents__agent_id__functions__function_id__enable_post",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "agent_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Agent Id"
            }
          },
          {
            "name": "function_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Function Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AttachFunctionResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/agents/{agent_id}/functions/{function_id}/disable": {
      "post": {
        "tags": [
          "Custom Functions"
        ],
        "summary": "Disable Function For Agent",
        "description": "Disable a function for this agent.\n\nThe function remains attached but won't be used in voice calls.\nFor agencies: requires sub-account context (X-Sub-Account-Id header).",
        "operationId": "disable_function_for_agent_agents__agent_id__functions__function_id__disable_post",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "agent_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Agent Id"
            }
          },
          {
            "name": "function_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Function Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AttachFunctionResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/agents/{agent_id}/functions/{function_id}": {
      "get": {
        "tags": [
          "Custom Functions"
        ],
        "summary": "Get Custom Function",
        "description": "Get a specific custom function attached to this agent.\n\nFor agencies: requires sub-account context (X-Sub-Account-Id header).",
        "operationId": "get_custom_function_agents__agent_id__functions__function_id__get",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "agent_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Agent Id"
            }
          },
          {
            "name": "function_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Function Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomFunctionResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      },
      "put": {
        "tags": [
          "Custom Functions"
        ],
        "summary": "Update Custom Function",
        "description": "Update a custom function.\n\n- is_enabled changes only affect this agent\n- Other changes affect all agents using this function\n\nFor agencies: requires sub-account context (X-Sub-Account-Id header).",
        "operationId": "update_custom_function_agents__agent_id__functions__function_id__put",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "agent_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Agent Id"
            }
          },
          {
            "name": "function_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Function Id"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CustomFunctionUpdate"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomFunctionResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Custom Functions"
        ],
        "summary": "Delete Custom Function",
        "description": "Delete a custom function from the library.\n\nWARNING: This removes the function from ALL agents, not just this one.\nUse /detach to remove from only this agent.\n\nFor agencies: requires sub-account context (X-Sub-Account-Id header).",
        "operationId": "delete_custom_function_agents__agent_id__functions__function_id__delete",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "agent_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Agent Id"
            }
          },
          {
            "name": "function_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Function Id"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Successful Response"
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/agents/{agent_id}/functions/{function_id}/test": {
      "post": {
        "tags": [
          "Custom Functions"
        ],
        "summary": "Test Custom Function",
        "description": "Test a custom function by calling its webhook.\n\nMakes a real HTTP request to the webhook URL with test arguments.\nReturns timing information and the webhook response.\n\nFor agencies: requires sub-account context (X-Sub-Account-Id header).",
        "operationId": "test_custom_function_agents__agent_id__functions__function_id__test_post",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "agent_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Agent Id"
            }
          },
          {
            "name": "function_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Function Id"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/FunctionTestRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FunctionTestResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/functions": {
      "get": {
        "tags": [
          "Functions"
        ],
        "summary": "List Library Functions",
        "description": "List all custom functions in the tenant's library.\n\nReturns functions with their attached agent information.\nFor agencies: requires sub-account context (X-Sub-Account-Id header).",
        "operationId": "list_library_functions_functions_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FunctionLibraryResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      },
      "post": {
        "tags": [
          "Functions"
        ],
        "summary": "Create Library Function",
        "description": "Create a new function in the tenant's library.\n\nThe function is not attached to any agent - use attach to add to agents.\nFor agencies: requires sub-account context (X-Sub-Account-Id header).",
        "operationId": "create_library_function_functions_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CustomFunctionCreate"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomFunctionResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/functions/{function_id}": {
      "get": {
        "tags": [
          "Functions"
        ],
        "summary": "Get Library Function",
        "description": "Get a specific function from the library with attached agents info.\n\nFor agencies: requires sub-account context (X-Sub-Account-Id header).",
        "operationId": "get_library_function_functions__function_id__get",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "function_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Function Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FunctionWithAgentsResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      },
      "put": {
        "tags": [
          "Functions"
        ],
        "summary": "Update Library Function",
        "description": "Update a function in the library.\n\nChanges affect all agents using this function.\nFor agencies: requires sub-account context (X-Sub-Account-Id header).",
        "operationId": "update_library_function_functions__function_id__put",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "function_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Function Id"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CustomFunctionUpdate"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomFunctionResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Functions"
        ],
        "summary": "Delete Library Function",
        "description": "Delete a function from the library.\n\nCascade removes from all agents.\nFor agencies: requires sub-account context (X-Sub-Account-Id header).",
        "operationId": "delete_library_function_functions__function_id__delete",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "function_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Function Id"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Successful Response"
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/functions/{function_id}/agents": {
      "get": {
        "tags": [
          "Functions"
        ],
        "summary": "List Function Agents",
        "description": "List all agents using a specific function.\n\nFor agencies: requires sub-account context (X-Sub-Account-Id header).",
        "operationId": "list_function_agents_functions__function_id__agents_get",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "function_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Function Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/functions/{function_id}/test": {
      "post": {
        "tags": [
          "Functions"
        ],
        "summary": "Test Library Function",
        "description": "Test a library function's webhook by making a real call.\n\nFor agencies: requires sub-account context (X-Sub-Account-Id header).",
        "operationId": "test_library_function_functions__function_id__test_post",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "function_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Function Id"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/FunctionTestRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FunctionTestResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/functions/{function_id}/copy": {
      "post": {
        "tags": [
          "Functions"
        ],
        "summary": "Copy Function To Sub Account",
        "description": "Copy a function to another sub-account (agency feature).\n\nRequires agency access - the target tenant must be a sub-account\nof the current agency.",
        "operationId": "copy_function_to_sub_account_functions__function_id__copy_post",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "function_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Function Id"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CopyFunctionRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomFunctionResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/functions/test-webhook": {
      "post": {
        "tags": [
          "Functions"
        ],
        "summary": "Test Webhook Url",
        "description": "Test a webhook URL before creating a function.\n\nMakes a real HTTP request to the provided webhook URL to verify\nconnectivity and response. Used by the function wizard to validate\nwebhook URLs before saving.",
        "operationId": "test_webhook_url_functions_test_webhook_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookTestRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FunctionTestResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/agents/wizard/update-prompt": {
      "post": {
        "tags": [
          "Agent Wizard",
          "Agent Wizard"
        ],
        "summary": "Update Prompt Endpoint",
        "description": "Update an existing system prompt using AI.\n\nMakes surgical modifications to the prompt based on the instruction,\npreserving the overall structure while adding/modifying specific parts.\n\n**Features:**\n- Preserves prompt structure\n- Converts negative instructions to positive framing\n- Adds anti-patterns to dedicated section\n- Optional: integrate custom functions documentation\n\n**Example:**\n```json\n{\n  \"current_prompt\": \"You are a helpful assistant...\",\n  \"instruction\": \"Add FAQ about return policy\"\n}\n```",
        "operationId": "update_prompt_endpoint_agents_wizard_update_prompt_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdatePromptRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UpdatePromptResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/agents/wizard/update-prompt-contact-intelligence": {
      "post": {
        "tags": [
          "Agent Wizard",
          "Agent Wizard"
        ],
        "summary": "Update Prompt Contact Intelligence Endpoint",
        "description": "Update a system prompt to add or remove Contact Intelligence instructions.\n\nThis endpoint helps users configure their agent prompts to leverage\ncaller context data (name, company, previous calls, tags, etc.).\n\n**Actions:**\n- `add`: Injects a \"## Caller Intelligence\" section and updates greeting\n- `remove`: Removes the CI section and reverts greeting to generic\n\n**Example:**\n```json\n{\n  \"current_prompt\": \"You are a helpful assistant...\",\n  \"action\": \"add\"\n}\n```",
        "operationId": "update_prompt_contact_intelligence_endpoint_agents_wizard_update_prompt_contact_intelligence_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ContactIntelligencePromptRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UpdatePromptResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/agents/wizard/generate-knowledge": {
      "post": {
        "tags": [
          "Agent Wizard",
          "Agent Wizard"
        ],
        "summary": "Generate Knowledge",
        "description": "Generate AI suggestions for a specific knowledge section.\n\nThis endpoint uses xAI to generate content for one section at a time,\nallowing users to iterate on each section individually.\n\n**Sections:**\n- `services`: Products and services offered\n- `pricing`: Pricing information\n- `team`: Team members and roles\n- `faqs`: Common questions and answers",
        "operationId": "generate_knowledge_agents_wizard_generate_knowledge_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/app__agents__prompt_router__GenerateKnowledgeRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenerateKnowledgeResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/agents/wizard/generate-all-knowledge": {
      "post": {
        "tags": [
          "Agent Wizard",
          "Agent Wizard"
        ],
        "summary": "Generate All Knowledge Endpoint",
        "description": "Generate all knowledge sections at once.\n\nThis is a convenience endpoint that generates services, pricing,\nteam, and FAQs in a single call. Takes longer but provides\neverything needed for the agent prompt.",
        "operationId": "generate_all_knowledge_endpoint_agents_wizard_generate_all_knowledge_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/app__agents__prompt_router__GenerateAllKnowledgeRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenerateAllKnowledgeResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/agents/wizard/enhance-description": {
      "post": {
        "tags": [
          "Agent Wizard",
          "Agent Wizard"
        ],
        "summary": "Enhance Description",
        "description": "Enhance a basic business description using AI.\n\nTakes a rough description and makes it more polished and professional\nwhile keeping it concise (under 50 words).",
        "operationId": "enhance_description_agents_wizard_enhance_description_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EnhanceDescriptionRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EnhanceDescriptionResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/agents/wizard/preview-prompt": {
      "post": {
        "tags": [
          "Agent Wizard",
          "Agent Wizard"
        ],
        "summary": "Preview Prompt",
        "description": "Preview the full generated prompt before creating the agent.\n\nThis builds the complete receptionist prompt from the provided\nknowledge sections and returns it along with recommended settings.",
        "operationId": "preview_prompt_agents_wizard_preview_prompt_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PreviewPromptRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PreviewPromptResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/agents/wizard/industry-presets": {
      "get": {
        "tags": [
          "Agent Wizard",
          "Agent Wizard"
        ],
        "summary": "Get Industry Presets",
        "description": "Get available industry presets.\n\nReturns a list of supported industries and their associated\nsuggestions for services and FAQs.",
        "operationId": "get_industry_presets_agents_wizard_industry_presets_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IndustryPresetsResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/agents/wizard/defaults": {
      "get": {
        "tags": [
          "Agent Wizard",
          "Agent Wizard"
        ],
        "summary": "Get Wizard Defaults",
        "description": "Get default settings for the agent wizard.\n\nReturns recommended settings for a receptionist agent.",
        "operationId": "get_wizard_defaults_agents_wizard_defaults_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "title": "Response Get Wizard Defaults Agents Wizard Defaults Get"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/agents/wizard/generate-function-schema": {
      "post": {
        "tags": [
          "Agent Wizard",
          "Agent Wizard"
        ],
        "summary": "Generate Function Schema Endpoint",
        "description": "Generate a custom function schema using AI.\n\nTakes a plain English description and generates:\n- Function name (snake_case)\n- Description for the AI to understand when to use it\n- JSON Schema for parameters\n- Recommended HTTP method (GET/POST)\n\n**Example:**\n```json\n{\n  \"description\": \"Capture lead info: name, email, phone number\"\n}\n```\n\nReturns a complete function definition ready for the custom function form.",
        "operationId": "generate_function_schema_endpoint_agents_wizard_generate_function_schema_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/GenerateFunctionSchemaRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenerateFunctionSchemaResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/agents/wizard/import-website": {
      "post": {
        "tags": [
          "Agent Wizard",
          "Agent Wizard"
        ],
        "summary": "Import From Website",
        "description": "Import business information from a website.\n\nThis endpoint:\n1. Scrapes the provided URL and discovers internal pages\n2. Scrapes up to 8 key pages (about, services, pricing, team, faq)\n3. Uses AI to extract business information from the combined content\n4. Returns structured data ready for the wizard form",
        "operationId": "import_from_website_agents_wizard_import_website_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ImportWebsiteRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ImportWebsiteResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/agents/wizard/import-website-stream": {
      "get": {
        "tags": [
          "Agent Wizard",
          "Agent Wizard"
        ],
        "summary": "Import From Website Stream",
        "description": "Import business information from a website with real-time progress streaming.\n\nReturns Server-Sent Events with progress updates:\n- progress: {step, current, total, detail}\n- result: {business_name, industry, ...}\n- error: {message}",
        "operationId": "import_from_website_stream_agents_wizard_import_website_stream_get",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "url",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 5,
              "maxLength": 500,
              "description": "Website URL to scrape",
              "title": "Url"
            },
            "description": "Website URL to scrape"
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/agents/wizard/suggest-functions": {
      "post": {
        "tags": [
          "Agent Wizard",
          "Agent Wizard"
        ],
        "summary": "Suggest Functions Endpoint",
        "description": "Get AI-powered function/tool suggestions for an agent.\n\nAnalyzes industry, agent mode, and business description to recommend\nwhich tools to enable, with a reason for each suggestion.",
        "operationId": "suggest_functions_endpoint_agents_wizard_suggest_functions_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SuggestFunctionsRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuggestFunctionsResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/agents/wizard/generate-expressive": {
      "post": {
        "tags": [
          "Agent Wizard",
          "Agent Wizard"
        ],
        "summary": "Generate Expressive Endpoint",
        "description": "Generate expressive voice configuration using AI.\n\nAnalyzes the agent's prompt and user preferences to generate:\n- Audio tags for ElevenLabs v3 expressive mode\n- Custom emotion tags with descriptions\n- A prompt section with tone/delivery guidance\n- The full updated prompt with the section merged in\n\nSupports presets, custom descriptions, and iterative refinement.",
        "operationId": "generate_expressive_endpoint_agents_wizard_generate_expressive_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/GenerateExpressiveRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenerateExpressiveResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/agents/wizard/preview-greeting-tts": {
      "post": {
        "tags": [
          "Agent Wizard",
          "Agent Wizard"
        ],
        "summary": "Preview Greeting Tts",
        "description": "Generate a TTS audio preview of a greeting message.\n\nCalls the appropriate TTS provider API and streams back MP3 audio.\nxAI falls back to OpenAI TTS with voice \"alloy\" (no REST TTS available).",
        "operationId": "preview_greeting_tts_agents_wizard_preview_greeting_tts_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PreviewGreetingTTSRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/phone-numbers/search": {
      "get": {
        "tags": [
          "Phone Numbers",
          "Phone Numbers"
        ],
        "summary": "Search Available Numbers",
        "description": "Search for available phone numbers to purchase.\n\nReturns a list of available numbers matching the criteria.",
        "operationId": "search_available_numbers_phone_numbers_search_get",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "area_code",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "description": "Filter by area code",
              "title": "Area Code"
            },
            "description": "Filter by area code"
          },
          {
            "name": "country",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "description": "ISO country code",
              "default": "US",
              "title": "Country"
            },
            "description": "ISO country code"
          },
          {
            "name": "contains",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "description": "Pattern to search for",
              "title": "Contains"
            },
            "description": "Pattern to search for"
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "maximum": 50,
              "minimum": 1,
              "description": "Max results",
              "default": 10,
              "title": "Limit"
            },
            "description": "Max results"
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/phone-numbers": {
      "post": {
        "tags": [
          "Phone Numbers",
          "Phone Numbers"
        ],
        "summary": "Purchase Phone Number",
        "description": "Purchase a phone number.\n\nThe number will be registered with Twilio and configured with\nthe appropriate webhook URLs for voice calls.\n\nNOTE: Only agencies can purchase phone numbers (not sub-accounts).\nAgencies must be in agency view (not viewing as sub-account) - the\nX-Sub-Account-Id header is rejected with a 403.",
        "operationId": "purchase_phone_number_phone_numbers_post",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PhoneNumberPurchase"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PhoneNumberResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "Phone Numbers",
          "Phone Numbers"
        ],
        "summary": "List Phone Numbers",
        "description": "List all phone numbers owned by the tenant.\nFor sub-accounts (or agencies viewing as sub-account), only shows numbers assigned to them.",
        "operationId": "list_phone_numbers_phone_numbers_get",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "sub_account_id",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "format": "uuid"
                },
                {
                  "type": "null"
                }
              ],
              "description": "Filter by sub-account",
              "title": "Sub Account Id"
            },
            "description": "Filter by sub-account"
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PhoneNumberListResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/phone-numbers/available-for-assignment": {
      "get": {
        "tags": [
          "Phone Numbers",
          "Phone Numbers"
        ],
        "summary": "Get Available For Assignment",
        "description": "Get all phone numbers available for assignment to sub-accounts.\nOnly returns agency's own numbers (not sub-account imported ones).",
        "operationId": "get_available_for_assignment_phone_numbers_available_for_assignment_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/phone-numbers/{phone_number_id}": {
      "get": {
        "tags": [
          "Phone Numbers",
          "Phone Numbers"
        ],
        "summary": "Get Phone Number",
        "description": "Get details of a specific phone number.",
        "operationId": "get_phone_number_phone_numbers__phone_number_id__get",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "phone_number_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Phone Number Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PhoneNumberResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "Phone Numbers",
          "Phone Numbers"
        ],
        "summary": "Update Phone Number",
        "description": "Update a phone number's properties.\n\nUse this to assign a phone number to an agent or update its friendly name.",
        "operationId": "update_phone_number_phone_numbers__phone_number_id__patch",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "phone_number_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Phone Number Id"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PhoneNumberUpdate"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PhoneNumberResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Phone Numbers",
          "Phone Numbers"
        ],
        "summary": "Release Phone Number",
        "description": "Delete a phone number from Leadlock.\n\nIMPORTANT: This only removes the number from Leadlock's database.\nThe number remains in your Twilio/GoHighLevel account and can be re-imported.\n\nTo permanently release a number from Twilio (so it can be purchased by others),\nuse the Twilio Console.",
        "operationId": "release_phone_number_phone_numbers__phone_number_id__delete",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "phone_number_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Phone Number Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/phone-numbers/{phone_number_id}/assign": {
      "post": {
        "tags": [
          "Phone Numbers",
          "Phone Numbers"
        ],
        "summary": "Assign Phone Number",
        "description": "Assign a phone number to a sub-account.\nPass sub_account_id=null to unassign.\nOnly agencies can use this endpoint.",
        "operationId": "assign_phone_number_phone_numbers__phone_number_id__assign_post",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "phone_number_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Phone Number Id"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AssignPhoneNumberRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/phone-numbers/twilio/list": {
      "get": {
        "tags": [
          "Phone Numbers",
          "Phone Numbers"
        ],
        "summary": "List Twilio Numbers",
        "description": "List all numbers in client's Twilio account.\n\nReturns numbers with import status indicating whether each number\nis already imported, available for import, or unavailable.",
        "operationId": "list_twilio_numbers_phone_numbers_twilio_list_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/phone-numbers/import": {
      "post": {
        "tags": [
          "Phone Numbers",
          "Phone Numbers"
        ],
        "summary": "Import Phone Numbers",
        "description": "Import one or more phone numbers from Twilio account.\n\nImports numbers with automatic webhook configuration for voice calls.\nLimited to 10 numbers per request to avoid rate limits and timeouts.",
        "operationId": "import_phone_numbers_phone_numbers_import_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ImportNumbersRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/PhoneNumberResponse"
                  },
                  "type": "array",
                  "title": "Response Import Phone Numbers Phone Numbers Import Post"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/phone-numbers/import/ghl": {
      "post": {
        "tags": [
          "Phone Numbers",
          "Phone Numbers"
        ],
        "summary": "Import Ghl Phone Numbers",
        "description": "Import one or more GoHighLevel phone numbers.\n\nGHL numbers are imported as SMS-capable (no voice) for future\nSMS/chat integration via Lead Connector.\n\nLimited to 10 numbers per request.",
        "operationId": "import_ghl_phone_numbers_phone_numbers_import_ghl_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ImportGHLNumbersRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/PhoneNumberResponse"
                  },
                  "type": "array",
                  "title": "Response Import Ghl Phone Numbers Phone Numbers Import Ghl Post"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/phone-numbers/{phone_number_id}/check-a2p": {
      "post": {
        "tags": [
          "Phone Numbers",
          "Phone Numbers"
        ],
        "summary": "Check A2P Status",
        "description": "Check and update A2P registration status for a phone number.\n\nThis endpoint:\n- Queries Twilio/GHL API to check A2P status\n- Updates database with current status\n- Returns A2P details and messaging_enabled flag\n\nUse this after completing A2P registration to verify status.",
        "operationId": "check_a2p_status_phone_numbers__phone_number_id__check_a2p_post",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "phone_number_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Phone Number Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true,
                  "title": "Response Check A2P Status Phone Numbers  Phone Number Id  Check A2P Post"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/phone-numbers/refresh-a2p-status": {
      "post": {
        "tags": [
          "Phone Numbers",
          "Phone Numbers"
        ],
        "summary": "Refresh All A2P Status",
        "description": "Refresh A2P status for all phone numbers belonging to current tenant.\n\nThis endpoint:\n- Checks A2P status for ALL tenant phone numbers\n- Updates database with current status\n- Returns summary of results\n\nUse cases:\n- After completing A2P registration in Twilio/GHL\n- Periodic status verification\n- Troubleshooting messaging issues",
        "operationId": "refresh_all_a2p_status_phone_numbers_refresh_a2p_status_post",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "title": "Response Refresh All A2P Status Phone Numbers Refresh A2P Status Post"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/phone-numbers/backfill-sms-webhooks": {
      "post": {
        "tags": [
          "Phone Numbers",
          "Phone Numbers"
        ],
        "summary": "Backfill Sms Webhooks",
        "description": "One-time backfill: set SMS webhook URL on all Twilio SMS-capable numbers\nfor the current tenant. Safe to call multiple times (idempotent).",
        "operationId": "backfill_sms_webhooks_phone_numbers_backfill_sms_webhooks_post",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/phone-numbers/{phone_number_id}/test-sms": {
      "post": {
        "tags": [
          "Phone Numbers",
          "Phone Numbers"
        ],
        "summary": "Send Test Sms",
        "description": "Send a test SMS message using the specified phone number.\n\nThis endpoint:\n- Validates phone number is SMS-capable\n- Validates A2P registration (required for US numbers)\n- Routes to Twilio or GoHighLevel based on phone number source\n- Returns delivery status\n\nRequirements:\n- Phone number must be sms_capable = true\n- Phone number must have messaging_enabled = true (A2P verified)\n- Recipient number must be in E.164 format (+14155551234)\n\nNOTE: Uses get_effective_tenant_id so sub-account users (or agency users\nimpersonating a sub-account) are correctly attributed in text metering\n(FORGE text-agent-metering Step 9, 2026-04-08 \u2014 Site #10 / Issue #148 pattern).\n\nArgs:\n    phone_number_id: UUID of phone number to send from\n    to: Recipient phone number (E.164 format)\n    message: Message text (optional, defaults to test message)\n\nReturns:\n    SMSResult with delivery status and provider details",
        "operationId": "send_test_sms_phone_numbers__phone_number_id__test_sms_post",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "phone_number_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Phone Number Id"
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Recipient phone number (E.164 format, e.g., +14155551234)",
              "title": "To"
            },
            "description": "Recipient phone number (E.164 format, e.g., +14155551234)"
          },
          {
            "name": "message",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "description": "Message text",
              "default": "Test message from Leadlock Voice Agent",
              "title": "Message"
            },
            "description": "Message text"
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/sms-pools/": {
      "get": {
        "tags": [
          "SMS Pools",
          "sms-pools"
        ],
        "summary": "List Pools",
        "description": "List active pools for the current tenant (owned or sub-account).",
        "operationId": "list_pools_sms_pools__get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/PoolResponse"
                  },
                  "type": "array",
                  "title": "Response List Pools Sms Pools  Get"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/sms-pools/import/list-services": {
      "get": {
        "tags": [
          "SMS Pools",
          "sms-pools"
        ],
        "summary": "List Available Services",
        "description": "List Twilio Messaging Services across all the tenant's Twilio integrations.",
        "operationId": "list_available_services_sms_pools_import_list_services_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/MSListItem"
                  },
                  "type": "array",
                  "title": "Response List Available Services Sms Pools Import List Services Get"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/sms-pools/import": {
      "post": {
        "tags": [
          "SMS Pools",
          "sms-pools"
        ],
        "summary": "Import Pool",
        "description": "Create a pool by importing an existing Twilio Messaging Service.",
        "operationId": "import_pool_sms_pools_import_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MSImportRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PoolResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/sms-pools/{pool_id}": {
      "get": {
        "tags": [
          "SMS Pools",
          "sms-pools"
        ],
        "summary": "Get Pool",
        "description": "Fetch a single pool with members + today's per-member stats.",
        "operationId": "get_pool_sms_pools__pool_id__get",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "pool_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Pool Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PoolResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "SMS Pools",
          "sms-pools"
        ],
        "summary": "Update Pool",
        "description": "Update the pool's per-number sending-config defaults (budget, split, rollover, reset tz).",
        "operationId": "update_pool_sms_pools__pool_id__patch",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "pool_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Pool Id"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PoolUpdate"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PoolResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "SMS Pools",
          "sms-pools"
        ],
        "summary": "Delete Pool",
        "description": "Soft-delete the pool (Twilio MS remains untouched \u2014 customer owns it).",
        "operationId": "delete_pool_sms_pools__pool_id__delete",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "pool_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Pool Id"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Successful Response"
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/sms-pools/{pool_id}/sync": {
      "post": {
        "tags": [
          "SMS Pools",
          "sms-pools"
        ],
        "summary": "Sync Pool",
        "description": "Reconcile local members with current Twilio MS membership (non-destructive).",
        "operationId": "sync_pool_sms_pools__pool_id__sync_post",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "pool_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Pool Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PoolResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/calls": {
      "get": {
        "tags": [
          "Calls",
          "Calls"
        ],
        "summary": "List Calls",
        "description": "List call logs for the tenant.\n\nReturns paginated call history with optional agent and direction filtering.\nRespects sub-account context when X-Sub-Account-Id header is present.",
        "operationId": "list_calls_calls_get",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "maximum": 100,
              "minimum": 1,
              "default": 50,
              "title": "Limit"
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0,
              "title": "Offset"
            }
          },
          {
            "name": "agent_id",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "format": "uuid"
                },
                {
                  "type": "null"
                }
              ],
              "description": "Filter by agent",
              "title": "Agent Id"
            },
            "description": "Filter by agent"
          },
          {
            "name": "direction",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "description": "Filter by direction (inbound, outbound, test, demo)",
              "title": "Direction"
            },
            "description": "Filter by direction (inbound, outbound, test, demo)"
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CallLogListResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/calls/export": {
      "get": {
        "tags": [
          "Calls",
          "Calls"
        ],
        "summary": "Export Calls",
        "description": "Export call logs as CSV.",
        "operationId": "export_calls_calls_export_get",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "agent_id",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "format": "uuid"
                },
                {
                  "type": "null"
                }
              ],
              "description": "Filter by agent",
              "title": "Agent Id"
            },
            "description": "Filter by agent"
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "description": "Filter by status",
              "title": "Status"
            },
            "description": "Filter by status"
          },
          {
            "name": "date_from",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "format": "date-time"
                },
                {
                  "type": "null"
                }
              ],
              "description": "Filter by start date",
              "title": "Date From"
            },
            "description": "Filter by start date"
          },
          {
            "name": "date_to",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "format": "date-time"
                },
                {
                  "type": "null"
                }
              ],
              "description": "Filter by end date",
              "title": "Date To"
            },
            "description": "Filter by end date"
          },
          {
            "name": "search",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "description": "Search term",
              "title": "Search"
            },
            "description": "Search term"
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/calls/{call_id}": {
      "get": {
        "tags": [
          "Calls",
          "Calls"
        ],
        "summary": "Get Call",
        "description": "Get details of a specific call.\nRespects sub-account context when X-Sub-Account-Id header is present.",
        "operationId": "get_call_calls__call_id__get",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "call_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Call Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CallLogResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/calls/{call_id}/recording": {
      "get": {
        "tags": [
          "Calls",
          "Calls"
        ],
        "summary": "Get Call Recording",
        "description": "Stream recording audio for a specific call.\n\nProxies the audio from Twilio's authenticated API so the browser\ncan play it without needing Twilio credentials.\nRespects sub-account context when X-Sub-Account-Id header is present.\n\nReturns:\n    StreamingResponse with audio/mpeg content\n\nRaises:\n    404: Call not found or no recording available",
        "operationId": "get_call_recording_calls__call_id__recording_get",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "call_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Call Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/calls/{call_id}/analyze": {
      "post": {
        "tags": [
          "Calls",
          "Calls"
        ],
        "summary": "Analyze Call",
        "description": "Analyze a call transcript using AI.\n\nReturns insights about call outcome, summary, key moments, and actionable improvements.\nUses xAI to analyze the transcript and provide coaching feedback.\n\nRespects sub-account context when X-Sub-Account-Id header is present.",
        "operationId": "analyze_call_calls__call_id__analyze_post",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "call_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Call Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/compliance/outbound": {
      "get": {
        "tags": [
          "Compliance",
          "Compliance"
        ],
        "summary": "Get Outbound Compliance",
        "description": "Get outbound calling compliance status for current tenant.",
        "operationId": "get_outbound_compliance_compliance_outbound_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OutboundComplianceStatus"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/compliance/outbound/accept": {
      "post": {
        "tags": [
          "Compliance",
          "Compliance"
        ],
        "summary": "Accept Outbound Compliance",
        "description": "Accept outbound calling terms. Records acceptance with audit trail.",
        "operationId": "accept_outbound_compliance_compliance_outbound_accept_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AcceptOutboundTermsRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OutboundComplianceStatus"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/outbound/agents/{agent_id}/call": {
      "post": {
        "tags": [
          "Outbound Calls",
          "Outbound Calls"
        ],
        "summary": "Initiate Outbound Call",
        "description": "Initiate an outbound call from a voice agent.\n\nThe agent will call the specified phone number and handle the conversation\nusing its configured AI settings.\n\nArgs:\n    agent_id: The agent to handle the call\n    request: Call details including recipient number\n\nReturns:\n    Call details including call_sid for tracking",
        "operationId": "initiate_outbound_call_outbound_agents__agent_id__call_post",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "agent_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Agent Id"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OutboundCallRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OutboundCallResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/outbound/trigger": {
      "post": {
        "tags": [
          "Outbound Calls",
          "Outbound Calls"
        ],
        "summary": "Trigger Outbound Call",
        "description": "Trigger an outbound call via webhook (for GHL, Zapier, etc.).\n\nAuthentication: API Key (X-API-Key header) or JWT Bearer token.\n\nThis endpoint is designed for external automation triggers like:\n- GoHighLevel workflow webhooks\n- Zapier/Make integrations\n- Custom automation scripts\n\nArgs:\n    request: Webhook payload with agent_id, to_number, and optional context\n\nReturns:\n    Call details including call_sid for tracking\n\nExample cURL:\n```\ncurl -X POST https://leadlock-app.onrender.com/outbound/trigger \\\n  -H \"X-API-Key: sk_live_xxx\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"agent_id\": \"uuid-here\",\n    \"to_number\": \"+14155551234\",\n    \"context\": {\n      \"first_name\": \"John\",\n      \"source\": \"GHL New Lead\"\n    }\n  }'\n```",
        "operationId": "trigger_outbound_call_outbound_trigger_post",
        "requestBody": {
          "description": "JSON is shown. This endpoint also accepts application/x-www-form-urlencoded and multipart/form-data, and unwraps GoHighLevel's `customData` object: any key inside it that is not a protocol field becomes a dynamic variable.",
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "agent_id": {
                    "type": "string",
                    "format": "uuid",
                    "title": "Agent Id",
                    "description": "Agent ID to handle the call"
                  },
                  "to_number": {
                    "type": "string",
                    "pattern": "^\\+(?:1[2-9]\\d{9}|[2-9]\\d{6,14})$",
                    "title": "To Number",
                    "description": "Recipient phone number in E.164 format"
                  },
                  "from_phone_number_id": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "uuid"
                      },
                      {
                        "type": "null"
                      }
                    ],
                    "title": "From Phone Number Id",
                    "description": "Specific phone number to call from"
                  },
                  "ghl_contact_id": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ],
                    "title": "Ghl Contact Id",
                    "description": "GHL contact ID for pre-flight conversation checks"
                  },
                  "context": {
                    "anyOf": [
                      {
                        "properties": {
                          "first_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "title": "First Name",
                            "description": "Contact's first name"
                          },
                          "last_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "title": "Last Name",
                            "description": "Contact's last name"
                          },
                          "email": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "title": "Email",
                            "description": "Contact's email"
                          },
                          "company": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "title": "Company",
                            "description": "Contact's company"
                          },
                          "source": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "title": "Source",
                            "description": "Lead source (e.g., 'GHL Workflow', 'Website Form')"
                          },
                          "notes": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "title": "Notes",
                            "description": "Additional context for the agent"
                          },
                          "custom_fields": {
                            "anyOf": [
                              {
                                "additionalProperties": true,
                                "type": "object"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "title": "Custom Fields",
                            "description": "Custom key-value pairs"
                          }
                        },
                        "type": "object",
                        "title": "WebhookCallContext",
                        "description": "Optional context to pass to the agent for personalization."
                      },
                      {
                        "type": "null"
                      }
                    ],
                    "description": "Context to personalize the call (injected into agent prompt)"
                  },
                  "dynamic_variables": {
                    "anyOf": [
                      {
                        "additionalProperties": {
                          "type": "string"
                        },
                        "type": "object"
                      },
                      {
                        "type": "null"
                      }
                    ],
                    "title": "Dynamic Variables",
                    "description": "Variables to substitute in prompt: {'customer_name': 'John', 'order_id': '12345'}. All values must be strings."
                  }
                },
                "type": "object",
                "required": [
                  "agent_id",
                  "to_number"
                ],
                "title": "WebhookTriggerRequest",
                "description": "Request body for webhook-triggered outbound calls.\n\nSupports two formats:\n- Direct: {\"agent_id\": \"...\", \"to_number\": \"...\"}  (n8n, Zapier, cURL)\n- GHL:    {\"customData\": {\"agent_id\": \"...\", \"to_number\": \"...\"}, ...}"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OutboundCallResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/outbound/sms": {
      "post": {
        "tags": [
          "Outbound Calls",
          "Outbound Calls"
        ],
        "summary": "Send Outbound Sms",
        "description": "Send an SMS from one of your own connected numbers (CRM webhook door).\n\nAuthentication: API Key (X-API-Key header) or JWT Bearer token. Designed for\nGHL/Zapier workflow webhooks that need to text a lead from your Twilio number\nrather than your CRM-connected one. Every number is one you imported from\nyour own Twilio or GHL account; the send uses that account's credentials.\n\nBody (JSON, form-encoded or multipart):\n{to_number, message, from_phone_number_id?, media_url?}. media_url attaches a\npublic https image and sends the message as MMS. When from_phone_number_id is\nomitted an SMS-capable number is auto-resolved, PREFERRING a Twilio-source one\n\u2014 if your only SMS-capable number came from GHL the send goes out on that, so\nthe number and provider actually used come back in the response.\n\nA rejected send (opt-out, carrier failure) still returns HTTP 200 with\nsuccess=false and an error string. Branch on success, not the status code.",
        "operationId": "send_outbound_sms_outbound_sms_post",
        "requestBody": {
          "description": "JSON is shown. This endpoint also accepts application/x-www-form-urlencoded and multipart/form-data. Note that a rejected send (opt-out, carrier failure) still returns HTTP 200 with `success: false` and an `error` string, so branch on `success` rather than the status code.",
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "to_number": {
                    "type": "string",
                    "title": "To Number",
                    "description": "Recipient in E.164 (formatted input is coerced)"
                  },
                  "message": {
                    "type": "string",
                    "maxLength": 1600,
                    "minLength": 1,
                    "title": "Message"
                  },
                  "from_phone_number_id": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "uuid"
                      },
                      {
                        "type": "null"
                      }
                    ],
                    "title": "From Phone Number Id",
                    "description": "Specific Leadlock number to send from; auto-resolved if omitted"
                  },
                  "media_url": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 2048
                      },
                      {
                        "type": "null"
                      }
                    ],
                    "title": "Media Url",
                    "description": "Public https URL of an image to send as MMS"
                  }
                },
                "type": "object",
                "required": [
                  "to_number",
                  "message"
                ],
                "title": "OutboundSMSRequest",
                "description": "Send an SMS from one of the tenant's own numbers (X-API-Key door for CRM webhooks).\n\nLets a GHL workflow send texts through the customer's connected Twilio number\nrather than their GHL-connected one. Both belong to the customer \u2014 Leadlock\nowns no numbers and no sending account; the send uses that integration's own\ncredentials. from_phone_number_id is optional: when omitted an SMS-capable\nnumber is auto-resolved, preferring a Twilio-source one."
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/webhooks/twilio/{tenant_id}/sms-status": {
      "post": {
        "tags": [
          "Webhooks",
          "Webhooks"
        ],
        "summary": "Handle Sms Status Callback",
        "description": "Twilio status callback for ALL SMS sends.\n\nEvery send sets a per-message status_callback URL that routes Twilio's\nqueued \u2192 sent \u2192 delivered/failed transitions back to us. POOL sends\nadditionally carry pool_member_id in the query string so delivery stats can\nbe attributed to the right pool member without secondary lookups.\n\n`member_id` is OPTIONAL. It used to be mandatory, which silently dropped\nevery non-pool callback \u2014 including the 30034 (unregistered A2P) failures\nthat made +16026696955 unable to text anyone from 2026-08-04 onward with\nnobody noticing for two days. Pool-member attribution is now the only part\ngated on member_id; idempotency, bad-number flagging and config-failure\nalerting run for every callback.\n\nReturns 204 on success (or duplicate); 403 on bad signature (handled by\nthe validate_twilio_signature dependency).",
        "operationId": "handle_sms_status_callback_webhooks_twilio__tenant_id__sms_status_post",
        "parameters": [
          {
            "name": "tenant_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Tenant Id"
            }
          },
          {
            "name": "x-twilio-signature",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Twilio-Signature"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "$ref": "#/components/schemas/Body_handle_sms_status_callback_webhooks_twilio__tenant_id__sms_status_post"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/webhooks/twilio/{tenant_id}/sms": {
      "post": {
        "tags": [
          "Webhooks",
          "Webhooks"
        ],
        "summary": "Handle Incoming Sms",
        "description": "Handle inbound SMS/MMS from Twilio.\n\nMMS attachments (images, voice notes) are extracted from the variable-count\nMediaUrl{N}/MediaContentType{N} form fields Twilio sends and passed to\n_process_incoming_sms for analysis via platform OpenAI key. Voice-only\nMMS (empty Body + audio attachment) are processed after transcription.",
        "operationId": "handle_incoming_sms_webhooks_twilio__tenant_id__sms_post",
        "parameters": [
          {
            "name": "tenant_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Tenant Id"
            }
          },
          {
            "name": "x-twilio-signature",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Twilio-Signature"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "$ref": "#/components/schemas/Body_handle_incoming_sms_webhooks_twilio__tenant_id__sms_post"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/webhooks/twilio/{tenant_id}/voice": {
      "post": {
        "tags": [
          "Webhooks",
          "Webhooks"
        ],
        "summary": "Handle Incoming Voice",
        "description": "Handle voice calls from Twilio (both inbound and outbound).\n\nFor inbound: Twilio calls us when someone dials our number\nFor outbound: Twilio calls us after we initiate via REST API\n\nReturns TwiML to connect the call to our Media Streams WebSocket.",
        "operationId": "handle_incoming_voice_webhooks_twilio__tenant_id__voice_post",
        "parameters": [
          {
            "name": "tenant_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Tenant Id"
            }
          },
          {
            "name": "x-twilio-signature",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Twilio-Signature"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "$ref": "#/components/schemas/Body_handle_incoming_voice_webhooks_twilio__tenant_id__voice_post"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/webhooks/twilio/{tenant_id}/status": {
      "post": {
        "tags": [
          "Webhooks",
          "Webhooks"
        ],
        "summary": "Handle Call Status",
        "description": "Handle call status updates from Twilio.\n\nUpdates the call log with status changes and duration when call completes.",
        "operationId": "handle_call_status_webhooks_twilio__tenant_id__status_post",
        "parameters": [
          {
            "name": "tenant_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Tenant Id"
            }
          },
          {
            "name": "x-twilio-signature",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Twilio-Signature"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "$ref": "#/components/schemas/Body_handle_call_status_webhooks_twilio__tenant_id__status_post"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/webhooks/twilio/{tenant_id}/recording": {
      "post": {
        "tags": [
          "Webhooks",
          "Webhooks"
        ],
        "summary": "Handle Recording Ready",
        "description": "Handle recording completion callback from Twilio.\n\nUpdates the call log with the recording URL.",
        "operationId": "handle_recording_ready_webhooks_twilio__tenant_id__recording_post",
        "parameters": [
          {
            "name": "tenant_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Tenant Id"
            }
          },
          {
            "name": "x-twilio-signature",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Twilio-Signature"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "$ref": "#/components/schemas/Body_handle_recording_ready_webhooks_twilio__tenant_id__recording_post"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/webhooks/twilio/{tenant_id}/amd-status": {
      "post": {
        "tags": [
          "Webhooks",
          "Webhooks"
        ],
        "summary": "Handle Amd Status",
        "description": "Handle AMD (Answering Machine Detection) results from Twilio.\n\nCalled asynchronously by Twilio when AMD determines whether a human\nor machine answered the outbound call.\n\nAnsweredBy values:\n- human: A person answered\n- machine_start: Voicemail detected (haven't waited for beep)\n- machine_end_beep: Voicemail beep detected\n- machine_end_silence: Voicemail silence detected\n- machine_end_other: Voicemail ended another way\n- fax: Fax machine detected\n- unknown: Unable to determine\n\nBased on agent's amd_voicemail_behavior, we either:\n- hangup: Immediately end the call\n- static_message: Play pre-configured voicemail message\n- dynamic_message: Play message with {{variable}} substitution\n- agent_decides: Let the AI agent handle it (no action here)",
        "operationId": "handle_amd_status_webhooks_twilio__tenant_id__amd_status_post",
        "parameters": [
          {
            "name": "tenant_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Tenant Id"
            }
          },
          {
            "name": "x-twilio-signature",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Twilio-Signature"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "$ref": "#/components/schemas/Body_handle_amd_status_webhooks_twilio__tenant_id__amd_status_post"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/webhooks/twilio/{tenant_id}/whisper/{call_sid}": {
      "get": {
        "tags": [
          "Webhooks",
          "Webhooks"
        ],
        "summary": "Handle Whisper",
        "description": "Serve whisper TwiML to Twilio when transfer recipient answers.\n\nGenerates a 2-3 sentence AI summary of the call transcript and returns\nit as <Say> TwiML. Falls back to empty response on any error.",
        "operationId": "handle_whisper_webhooks_twilio__tenant_id__whisper__call_sid__get",
        "parameters": [
          {
            "name": "tenant_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Tenant Id"
            }
          },
          {
            "name": "call_sid",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Call Sid"
            }
          },
          {
            "name": "x-twilio-signature",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Twilio-Signature"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Webhooks",
          "Webhooks"
        ],
        "summary": "Handle Whisper",
        "description": "Serve whisper TwiML to Twilio when transfer recipient answers.\n\nGenerates a 2-3 sentence AI summary of the call transcript and returns\nit as <Say> TwiML. Falls back to empty response on any error.",
        "operationId": "handle_whisper_webhooks_twilio__tenant_id__whisper__call_sid__post",
        "parameters": [
          {
            "name": "tenant_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Tenant Id"
            }
          },
          {
            "name": "call_sid",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Call Sid"
            }
          },
          {
            "name": "x-twilio-signature",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Twilio-Signature"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/webhooks/drop-cowboy/{tenant_id}/{secret}/status": {
      "post": {
        "tags": [
          "Webhooks",
          "Webhooks"
        ],
        "summary": "Handle Drop Cowboy Status",
        "description": "Receive a Drop Cowboy RVM delivery-status (CDR) callback.\n\nReturns 204 on success or duplicate; 403 on a bad token. Always 204 on our\nown internal errors so a failure here never turns into a retry storm.",
        "operationId": "handle_drop_cowboy_status_webhooks_drop_cowboy__tenant_id___secret__status_post",
        "parameters": [
          {
            "name": "tenant_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Tenant Id"
            }
          },
          {
            "name": "secret",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Secret"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/webhooks/stripe": {
      "post": {
        "tags": [
          "Webhooks",
          "Webhooks"
        ],
        "summary": "Handle Stripe Webhook",
        "description": "Handle incoming Stripe webhook events.\n\nSecurity checks (in order):\n1. Verify signature header exists\n2. Verify webhook secret is configured\n3. Validate timestamp (CRIT-005 - replay protection)\n4. Verify signature using Stripe SDK\n5. Check deduplication (CRIT-003 - idempotency)\n6. Validate required fields (CRIT-004)\n7. Process event",
        "operationId": "handle_stripe_webhook_webhooks_stripe_post",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          }
        }
      }
    },
    "/webhooks/stripe/connect": {
      "post": {
        "tags": [
          "Webhooks",
          "Webhooks"
        ],
        "summary": "Handle Stripe Connect Webhook",
        "description": "Receive an event from an agency's connected Stripe account.",
        "operationId": "handle_stripe_connect_webhook_webhooks_stripe_connect_post",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          }
        }
      }
    },
    "/webhooks/events": {
      "get": {
        "tags": [
          "Webhooks",
          "Webhooks"
        ],
        "summary": "List Webhook Events",
        "description": "Return a manifest of all supported webhook event types with payload schemas.\n\nRequires authentication (session or API key).",
        "operationId": "list_webhook_events_webhooks_events_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "title": "Response List Webhook Events Webhooks Events Get"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/integrations/calendar/auth": {
      "get": {
        "tags": [
          "Integrations",
          "GHL OAuth"
        ],
        "summary": "Ghl Auth Initiate",
        "description": "Initiate GHL OAuth flow.\n\nReturns the OAuth URL for the user to authorize access.\n\nSupports agency impersonation: If X-Sub-Account-Id header is present,\nthe integration will be created for the sub-account's tenant.",
        "operationId": "ghl_auth_initiate_integrations_calendar_auth_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/integrations/calendar/callback": {
      "get": {
        "tags": [
          "Integrations",
          "GHL OAuth"
        ],
        "summary": "Ghl Auth Callback",
        "description": "Handle GHL OAuth callback.\n\nExchanges the authorization code for tokens and stores them.\nSupports two flows:\n- User-initiated (from our app): state parameter present with tenant_id\n- Marketplace install (from GHL): no state parameter, tenant resolved from token response",
        "operationId": "ghl_auth_callback_integrations_calendar_callback_get",
        "parameters": [
          {
            "name": "code",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Code"
            }
          },
          {
            "name": "state",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "State"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/integrations": {
      "get": {
        "tags": [
          "Integrations"
        ],
        "summary": "List Integrations",
        "description": "List all connected integrations for the current tenant.\nSupports sub-account context via X-Sub-Account-Id header.\n\nFor sub-accounts: Returns integrations ASSIGNED via sub_account_integrations table.\nFor regular tenants: Returns integrations directly owned by the tenant.",
        "operationId": "list_integrations_integrations_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/IntegrationStatus"
                  },
                  "type": "array",
                  "title": "Response List Integrations Integrations Get"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/integrations/ghl/connect-api-key": {
      "post": {
        "tags": [
          "Integrations"
        ],
        "summary": "Connect Ghl Api Key",
        "description": "Connect GoHighLevel using a Private Integration API key.\n\nAlternative to OAuth for when marketplace approval is pending.\nValidates the key against GHL API, encrypts, and stores.\n\nArgs:\n    request: API key and location ID\n    current_user: Current authenticated user\n    tenant_id: Current tenant ID (supports sub-account context)\n\nReturns:\n    Success status with location name\n\nRaises:\n    HTTPException 400: If API key is invalid or location not found",
        "operationId": "connect_ghl_api_key_integrations_ghl_connect_api_key_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/GHLApiKeyRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/integrations/integration/{integration_id}": {
      "delete": {
        "tags": [
          "Integrations"
        ],
        "summary": "Disconnect Integration By Id",
        "description": "Disconnect a specific integration by ID.\n\nThis removes the stored tokens but doesn't revoke access at the provider.\nAllows disconnecting individual integrations when multiple of the same provider exist.\n\nNOTE: Uses the user's ACTUAL tenant_id (not sub-account context) because\nintegrations are always owned by the tenant that connected them, not sub-accounts.\nSub-accounts only have integration ASSIGNMENTS via sub_account_integrations table.",
        "operationId": "disconnect_integration_by_id_integrations_integration__integration_id__delete",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "integration_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Integration Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/integrations/{provider}": {
      "delete": {
        "tags": [
          "Integrations"
        ],
        "summary": "Disconnect Integration",
        "description": "DEPRECATED: Disconnect an integration by provider name.\n\nThis endpoint deletes ALL integrations of the given provider type.\nUse DELETE /integration/{integration_id} instead to delete a specific integration.\n\nThis removes the stored tokens but doesn't revoke access at the provider.\n\nNOTE: Uses the user's ACTUAL tenant_id (not sub-account context) because\nintegrations are always owned by the tenant that connected them.",
        "operationId": "disconnect_integration_integrations__provider__delete",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "provider",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Provider"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/integrations/ghl/integrations": {
      "get": {
        "tags": [
          "Integrations"
        ],
        "summary": "List Ghl Integrations",
        "description": "List all GoHighLevel integrations available to the tenant.\nIncludes both:\n- Integrations owned directly by this tenant\n- Integrations assigned to this sub-account from parent agency\nSupports sub-account context via X-Sub-Account-Id header.",
        "operationId": "list_ghl_integrations_integrations_ghl_integrations_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/GHLIntegrationInfo"
                  },
                  "type": "array",
                  "title": "Response List Ghl Integrations Integrations Ghl Integrations Get"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/integrations/ghl/calendars": {
      "get": {
        "tags": [
          "Integrations"
        ],
        "summary": "List Ghl Calendars",
        "description": "List available GoHighLevel calendars for a specific integration.\n\nArgs:\n    integration_id: The UUID of the GHL integration to fetch calendars from.\n                   Use GET /integrations/ghl/integrations to list available integrations.\nSupports sub-account context via X-Sub-Account-Id header.",
        "operationId": "list_ghl_calendars_integrations_ghl_calendars_get",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "integration_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Integration Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/CalendarInfo"
                  },
                  "title": "Response List Ghl Calendars Integrations Ghl Calendars Get"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/integrations/ghl/timezones": {
      "get": {
        "tags": [
          "Integrations"
        ],
        "summary": "List Ghl Timezones",
        "description": "Return the IANA timezones GHL supports for the current tenant's sub-account.\n\nPicks any active GHL integration on the tenant (or assigned to this sub-account)\nand calls GET /locations/:locationId/timezones. Result is cached in-process for\n7 days since GHL's list is effectively static.\n\nReturns an empty list if no active GHL integration exists \u2014 frontend falls back\nto the full IANA set via Intl.supportedValuesOf('timeZone').",
        "operationId": "list_ghl_timezones_integrations_ghl_timezones_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "items": {
                    "type": "string"
                  },
                  "type": "array",
                  "title": "Response List Ghl Timezones Integrations Ghl Timezones Get"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/integrations/ghl/phone-numbers": {
      "get": {
        "tags": [
          "Integrations"
        ],
        "summary": "List Ghl Phone Numbers",
        "description": "List phone numbers from GoHighLevel location.\n\nNOTE: GHL API does not support adding phone numbers programmatically.\nThis is display-only - users must manually import numbers via GHL UI.\n\nArgs:\n    integration_id: Optional specific GHL integration ID to fetch numbers from.\n                   If not provided, uses first active GHL integration.\n\nReturns:\n    List of phone numbers formatted for frontend:\n    - phone_number: E.164 format\n    - friendly_name: Display name\n    - capabilities: {voice: bool, sms: bool, mms: bool}\nSupports sub-account context via X-Sub-Account-Id header.",
        "operationId": "list_ghl_phone_numbers_integrations_ghl_phone_numbers_get",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "integration_id",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "format": "uuid"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Integration Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/integrations/ghl/status": {
      "get": {
        "tags": [
          "Integrations"
        ],
        "summary": "Get Ghl Status",
        "description": "Get GoHighLevel integration connection status.\n\nReturns connection status and location information.\nSupports sub-account context via X-Sub-Account-Id header.\n\nChecks both:\n- Integrations owned directly by this tenant\n- Integrations assigned to this sub-account from parent agency",
        "operationId": "get_ghl_status_integrations_ghl_status_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/integrations/ghl/disconnect": {
      "delete": {
        "tags": [
          "Integrations"
        ],
        "summary": "Disconnect Ghl",
        "description": "DEPRECATED: Disconnect GoHighLevel integration.\n\nThis endpoint deactivates ALL GHL integrations for the tenant.\nUse DELETE /integration/{integration_id} instead to disconnect a specific integration.\n\nRemoves stored OAuth tokens and deactivates integration.\n\nNOTE: Uses the user's ACTUAL tenant_id (not sub-account context) because\nintegrations are always owned by the tenant that connected them.",
        "operationId": "disconnect_ghl_integrations_ghl_disconnect_delete",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/integrations/ghl/{integration_id}/tags": {
      "get": {
        "tags": [
          "Integrations"
        ],
        "summary": "List Ghl Tags",
        "description": "List available tags from GoHighLevel location.\n\nReturns all tags configured in the GHL location that can be\napplied to contacts via the add_tag/remove_tag tools.",
        "operationId": "list_ghl_tags_integrations_ghl__integration_id__tags_get",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "integration_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Integration Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Integrations"
        ],
        "summary": "Create Ghl Tag",
        "description": "Create a new tag in the GoHighLevel location.\n\nBody: { \"name\": \"tag-name\" }",
        "operationId": "create_ghl_tag_integrations_ghl__integration_id__tags_post",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "integration_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Integration Id"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true,
                "title": "Body"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/integrations/ghl/{integration_id}/custom-fields": {
      "get": {
        "tags": [
          "Integrations"
        ],
        "summary": "List Ghl Custom Fields",
        "description": "List available custom fields from GoHighLevel location.\n\nReturns all custom fields configured in the GHL location that can be\nupdated via the update_custom_fields tool.",
        "operationId": "list_ghl_custom_fields_integrations_ghl__integration_id__custom_fields_get",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "integration_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Integration Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/integrations/ghl/{integration_id}/workflows": {
      "get": {
        "tags": [
          "Integrations"
        ],
        "summary": "List Ghl Workflows",
        "description": "List available workflows from GoHighLevel location.\n\nReturns all workflows configured in the GHL location that can be\ntriggered via the trigger_workflow tool.",
        "operationId": "list_ghl_workflows_integrations_ghl__integration_id__workflows_get",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "integration_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Integration Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/integrations/ghl/{integration_id}/pipelines": {
      "get": {
        "tags": [
          "Integrations"
        ],
        "summary": "List Ghl Pipelines",
        "description": "List available pipelines from GoHighLevel location.\n\nReturns all pipelines and their stages configured in the GHL location\nthat can be used with create_opportunity/update_opportunity_stage tools.",
        "operationId": "list_ghl_pipelines_integrations_ghl__integration_id__pipelines_get",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "integration_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Integration Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/integrations/ghl/{integration_id}/location-details": {
      "get": {
        "tags": [
          "Integrations"
        ],
        "summary": "Get Ghl Location Details",
        "description": "Fetch full location details from GoHighLevel API.\n\nReturns location name, email, phone, address, and other details\nto auto-fill sub-account creation form.\n\nSupports both direct ownership and junction table assignment for sub-accounts.",
        "operationId": "get_ghl_location_details_integrations_ghl__integration_id__location_details_get",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "integration_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Integration Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/integrations/twilio/connect": {
      "post": {
        "tags": [
          "integrations"
        ],
        "summary": "Connect Twilio",
        "description": "Connect tenant's Twilio account with API credentials.\n\nUnlike OAuth integrations, this accepts credentials directly.\nCredentials are validated by testing API connection before saving.\n\nArgs:\n    request: Account SID and Auth Token\n    current_user: Current authenticated user\n    tenant_id: Current tenant ID\n\nReturns:\n    Success status and saved integration data\n\nRaises:\n    HTTPException 400: If credentials are invalid",
        "operationId": "connect_twilio_integrations_twilio_connect_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TwilioCredentialsRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/integrations/twilio/disconnect": {
      "delete": {
        "tags": [
          "integrations"
        ],
        "summary": "Disconnect Twilio",
        "description": "Disconnect tenant's Twilio account.\n\nRemoves stored credentials from database.\nPhone numbers provisioned with this account will stop working.\n\nArgs:\n    current_user: Current authenticated user\n    tenant_id: Current tenant ID\n\nReturns:\n    Success status\n\nRaises:\n    HTTPException 404: If no Twilio integration found",
        "operationId": "disconnect_twilio_integrations_twilio_disconnect_delete",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/integrations/twilio/status": {
      "get": {
        "tags": [
          "integrations"
        ],
        "summary": "Get Twilio Status",
        "description": "Check Twilio integration status with live credential validation.\n\nMakes a real Twilio API call to verify credentials are valid and the\naccount is in good standing (not suspended, negative balance, etc.).\n\nArgs:\n    current_user: Current authenticated user\n    tenant_id: Current tenant ID\n\nReturns:\n    Connection status, health status, masked account SID, metadata",
        "operationId": "get_twilio_status_integrations_twilio_status_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/billing/checkout": {
      "post": {
        "tags": [
          "Billing"
        ],
        "summary": "Create Checkout Session",
        "description": "Create a Stripe Checkout session for subscription signup.\n\nOnly tenant owner can initiate subscription.",
        "operationId": "create_checkout_session_billing_checkout_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CheckoutRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CheckoutResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/billing/checkout-public": {
      "post": {
        "tags": [
          "Billing"
        ],
        "summary": "Create Public Checkout",
        "description": "Create Stripe checkout session for unauthenticated users (Stripe-first signup).\n\nAccount will be created via webhook after payment succeeds.\nNo authentication required - this is a public endpoint.",
        "operationId": "create_public_checkout_billing_checkout_public_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PublicCheckoutRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CheckoutResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/billing/portal": {
      "post": {
        "tags": [
          "Billing"
        ],
        "summary": "Create Portal Session",
        "description": "Create a Stripe Customer Portal session with product filtering.\n\nShows only relevant upgrade options based on current tier:\n- Starter: Agency/Pro upgrades\n- Agency: Pro upgrade only\n- Pro: White-Label addon\n\nAllows customer to manage subscription, payment methods, and view invoices.\nOnly tenant owner can access portal.",
        "operationId": "create_portal_session_billing_portal_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PortalRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PortalResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/billing/change-plan": {
      "post": {
        "tags": [
          "Billing"
        ],
        "summary": "Change Plan",
        "description": "Move an existing subscription to a higher plan.\n\nThis endpoint exists because the Stripe Customer Portal cannot do it. Every\nLeadlock subscription carries one licensed item plus ~14 metered items, and\nStripe refuses a portal subscription_update on any multi-item subscription\n(verified against all 26 live subscriptions, 2026-08-26). Before this, the\nonly self-serve subscription action a paying customer had was Cancel:\n/checkout 409s once you have a subscription, and the portal it redirects you\nto has no plan-change option to show.\n\nUpgrades only. Downgrades go through support (see DOWNGRADE_MESSAGE).",
        "operationId": "change_plan_billing_change_plan_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ChangePlanRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChangePlanResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/billing/apply-coupon": {
      "post": {
        "tags": [
          "Billing"
        ],
        "summary": "Apply Coupon",
        "description": "Apply a promotion code to an existing subscription.\n\nLooks up the promotion code in Stripe, validates it's active,\nand applies the associated coupon to the subscription.",
        "operationId": "apply_coupon_billing_apply_coupon_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ApplyCouponRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApplyCouponResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/billing/offers": {
      "get": {
        "tags": [
          "Billing"
        ],
        "summary": "Get Public Offers",
        "description": "Which course offers checkout honours right now (DAN-350).\n\nPublic and unauthenticated: the signup page asks before it promises a free\nfirst month or the Launch Bundle, so a link that goes out before the Stripe\nenv vars are set (or after one is cleared) shows the normal page instead.\nReads settings only, no I/O. Cached for five minutes at the edge and in the\nbrowser.",
        "operationId": "get_public_offers_billing_offers_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OffersResponse"
                }
              }
            }
          }
        }
      }
    },
    "/billing/limits": {
      "get": {
        "tags": [
          "Billing"
        ],
        "summary": "Get Tier Limits Endpoint",
        "description": "Get current tier limits and usage for the tenant.\n\nReturns current counts vs limits for agents, sub-accounts, team members,\nand share links, plus feature availability flags and voice rates.\nRespects sub-account context when X-Sub-Account-Id header is present.",
        "operationId": "get_tier_limits_endpoint_billing_limits_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TierLimitsResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/billing": {
      "get": {
        "tags": [
          "Billing"
        ],
        "summary": "Get Subscription Status",
        "description": "Get current subscription status and usage summary.",
        "operationId": "get_subscription_status_billing_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SubscriptionStatus"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/billing/invoices": {
      "get": {
        "tags": [
          "Billing"
        ],
        "summary": "Get Invoices",
        "description": "Get invoice history from Stripe.\n\nEXP-2: uses get_effective_tenant_id so an agency \"Operating as\nSub-Account\" sees the sub-account's invoices (usually none - the\nagency pays Stripe), never its own leaking into the sub view.\nTenants without a stripe_customer_id get an empty list, not an error.",
        "operationId": "get_invoices_billing_invoices_get",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "default": 10,
              "title": "Limit"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InvoiceListResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/billing/open-invoice": {
      "get": {
        "tags": [
          "Billing"
        ],
        "summary": "Get Open Invoice",
        "description": "Return the current open (unpaid) invoice for the owner's Stripe customer,\nwith the hosted pay-page URL. Powers the past-due payment-required overlay.\n\nOwner-only (require_owner). Resolves the owner's OWN stripe_customer_id -\nthe overlay only renders for the agency/direct tenant who can actually pay,\nso no sub-account -> parent walk is needed. Returns null when there is no\nopen invoice (not a 404).",
        "operationId": "get_open_invoice_billing_open_invoice_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/OpenInvoiceResponse"
                    },
                    {
                      "type": "null"
                    }
                  ],
                  "title": "Response Get Open Invoice Billing Open Invoice Get"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/billing/usage": {
      "get": {
        "tags": [
          "Billing"
        ],
        "summary": "Get Usage Records",
        "description": "Get usage records for the current billing period.",
        "operationId": "get_usage_records_billing_usage_get",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "default": 50,
              "title": "Limit"
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "default": 0,
              "title": "Offset"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UsageListResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/billing/usage/timeseries": {
      "get": {
        "tags": [
          "Billing"
        ],
        "summary": "Get Usage Timeseries",
        "description": "Daily usage for the current billing period, with a running total.\n\nOne row per UTC day of the whole period (zero-filled, future days flagged),\nat the price this tenant was charged: a sub-account sees its agency's price,\na direct customer its plan price. The window is the tenant's own period\n(resolve_usage_period), the same one /stats and /billing/my-billing use, so\nthe last running total equals the period totals on those screens. No\nprojection of the final bill.\n\nNOTE: Uses get_effective_tenant_id so an agency \"Operating as Sub-Account\"\nsees that sub-account's usage.",
        "operationId": "get_usage_timeseries_billing_usage_timeseries_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UsageTimeseriesResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/billing/invoices/upcoming": {
      "get": {
        "tags": [
          "Billing"
        ],
        "summary": "Get Upcoming Invoice",
        "description": "Get upcoming invoice preview.\n\nShows what will be charged when trial ends or at next billing cycle.",
        "operationId": "get_upcoming_invoice_billing_invoices_upcoming_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UpcomingInvoiceResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/billing/my-billing": {
      "get": {
        "tags": [
          "Billing"
        ],
        "summary": "Get My Billing",
        "description": "Get sub-account's billing info and usage for current period.\n\nSub-accounts don't have credit balances anymore (metered billing).\nShows usage this period and confirms billing goes to parent agency.\n\nNOTE: Uses get_effective_tenant_id to support agency impersonation.\nWhen agency user is \"Operating as Sub-Account\", the X-Sub-Account-Id\nheader is used to get the sub-account's billing info.",
        "operationId": "get_my_billing_billing_my_billing_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SubAccountBillingResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/agency/sub-accounts": {
      "get": {
        "tags": [
          "Agency Management"
        ],
        "summary": "List Sub Accounts",
        "description": "List all sub-accounts for the agency.\n\nReturns sub-accounts with billing info and usage stats.",
        "operationId": "list_sub_accounts_agency_sub_accounts_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SubAccountListResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      },
      "post": {
        "tags": [
          "Agency Management"
        ],
        "summary": "Create Sub Account",
        "description": "Create a new sub-account.\n\nValidates:\n- Agency has not exceeded sub_account_limit\n- Slug is globally unique",
        "operationId": "create_sub_account_agency_sub_accounts_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateSubAccountRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SubAccountResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/agency/sub-accounts/check-slug": {
      "post": {
        "tags": [
          "Agency Management"
        ],
        "summary": "Check Slug Availability",
        "description": "Check if a slug is available for use.\n\nReturns availability status without creating anything.\nUseful for real-time validation in the UI.",
        "operationId": "check_slug_availability_agency_sub_accounts_check_slug_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CheckSlugRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CheckSlugResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/agency/sub-accounts/default": {
      "post": {
        "tags": [
          "Agency Management"
        ],
        "summary": "Ensure Default Sub Account",
        "description": "Get the agency's first sub-account, creating it if there is none (DAN-467).\n\nIdempotent: an agency that already has an active sub-account gets that one\nback with created=false. Otherwise one is created (named after the agency,\nno admin user, no invite email), using one plan slot. Lets a brand-new\naccount reach a working API key and MCP connector without hand-creating a\nsub-account first. 403 while impersonating, and for non-agency tenants.",
        "operationId": "ensure_default_sub_account_agency_sub_accounts_default_post",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DefaultSubAccountResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/agency/sub-accounts/{sub_account_id}": {
      "get": {
        "tags": [
          "Agency Management"
        ],
        "summary": "Get Sub Account",
        "description": "Get a single sub-account with full details.",
        "operationId": "get_sub_account_agency_sub_accounts__sub_account_id__get",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "sub_account_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Sub Account Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SubAccountResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "Agency Management"
        ],
        "summary": "Update Sub Account",
        "description": "Update a sub-account's settings.",
        "operationId": "update_sub_account_agency_sub_accounts__sub_account_id__patch",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "sub_account_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Sub Account Id"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateSubAccountRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SubAccountResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Agency Management"
        ],
        "summary": "Delete Sub Account",
        "description": "Soft-delete a sub-account (sets is_active=False).\n\nHistorical data is preserved.",
        "operationId": "delete_sub_account_agency_sub_accounts__sub_account_id__delete",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "sub_account_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Sub Account Id"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Successful Response"
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/agency/sub-accounts/{sub_account_id}/invite": {
      "post": {
        "tags": [
          "Agency Management"
        ],
        "summary": "Send Sub Account Invite",
        "description": "Send an invitation email to the sub-account admin.",
        "operationId": "send_sub_account_invite_agency_sub_accounts__sub_account_id__invite_post",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "sub_account_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Sub Account Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/agency/sub-accounts/{sub_account_id}/usage": {
      "get": {
        "tags": [
          "Agency Management"
        ],
        "summary": "Get Sub Account Usage",
        "description": "Get usage records for a specific sub-account.\n\nWith no dates (API-key callers excepted: they get all history), covers\nthe agency's current billing period (the Stripe\nperiod his invoice uses), which the response also returns.",
        "operationId": "get_sub_account_usage_agency_sub_accounts__sub_account_id__usage_get",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "sub_account_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Sub Account Id"
            }
          },
          {
            "name": "date_from",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "format": "date-time"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Date From"
            }
          },
          {
            "name": "date_to",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "format": "date-time"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Date To"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "maximum": 1000,
              "minimum": 1,
              "default": 100,
              "title": "Limit"
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0,
              "title": "Offset"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UsageExportResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/agency/usage": {
      "get": {
        "tags": [
          "Agency Management"
        ],
        "summary": "Get All Usage",
        "description": "Get usage records across all sub-accounts.\n\nWith no dates (API-key callers excepted: they get all history), covers\nthe agency's current billing period (the Stripe\nperiod his invoice uses), which the response also returns so the Usage\nReports date pickers default to it.",
        "operationId": "get_all_usage_agency_usage_get",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "date_from",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "format": "date-time"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Date From"
            }
          },
          {
            "name": "date_to",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "format": "date-time"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Date To"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "maximum": 1000,
              "minimum": 1,
              "default": 100,
              "title": "Limit"
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0,
              "title": "Offset"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UsageExportResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/agency/usage/timeseries": {
      "get": {
        "tags": [
          "Agency Management"
        ],
        "summary": "Get Agency Usage Timeseries",
        "description": "Daily usage over the agency's current billing period, with a running total.\n\nOne row per UTC day of the whole Stripe period (zero-filled, future days\nflagged), priced at what Stripe bills the agency, voice and text. The last\nrunning total equals the voice plus text cost on the agency's Billing page\n(the overview's cost card is voice only). Optionally narrowed to one\nsub-account. No projection.",
        "operationId": "get_agency_usage_timeseries_agency_usage_timeseries_get",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "sub_account_id",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "format": "uuid"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Sub Account Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UsageTimeseriesResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/agency/usage/export": {
      "get": {
        "tags": [
          "Agency Management"
        ],
        "summary": "Export Usage Csv",
        "description": "Export usage data as CSV.\n\nReturns a streaming response to handle large datasets efficiently. With no\ndates, exports the agency's current billing period (API-key\ncallers: all history).",
        "operationId": "export_usage_csv_agency_usage_export_get",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "sub_account_id",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "format": "uuid"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Sub Account Id"
            }
          },
          {
            "name": "date_from",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "format": "date-time"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Date From"
            }
          },
          {
            "name": "date_to",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "format": "date-time"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Date To"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/agency/branding": {
      "get": {
        "tags": [
          "Agency Management"
        ],
        "summary": "Get Branding",
        "description": "Get branding settings.\n\nWorks for both agencies (own settings) and sub-accounts (parent settings).\nWhen impersonating, renders the sub-account's branding (BrandingService\nresolves up to the parent).",
        "operationId": "get_branding_agency_branding_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BrandingSettings"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      },
      "patch": {
        "tags": [
          "Agency Management"
        ],
        "summary": "Update Branding",
        "description": "Update branding settings.\n\nOnly agencies can update branding.",
        "operationId": "update_branding_agency_branding_patch",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateBrandingRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BrandingSettings"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/agency/branding/logo": {
      "post": {
        "tags": [
          "Agency Management"
        ],
        "summary": "Upload Logo",
        "description": "Upload a logo image.\n\nAccepts PNG, JPEG, SVG, or ICO. Maximum 5MB.",
        "operationId": "upload_logo_agency_branding_logo_post",
        "requestBody": {
          "content": {
            "multipart/form-data": {
              "schema": {
                "$ref": "#/components/schemas/Body_upload_logo_agency_branding_logo_post"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LogoUploadResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      },
      "delete": {
        "tags": [
          "Agency Management"
        ],
        "summary": "Delete Logo",
        "description": "Delete the logo image and clear logo_url. Returns refreshed branding.",
        "operationId": "delete_logo_agency_branding_logo_delete",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BrandingSettings"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/agency/branding/favicon": {
      "post": {
        "tags": [
          "Agency Management"
        ],
        "summary": "Upload Favicon",
        "description": "Upload a favicon image.\n\nAccepts PNG, JPEG, SVG, or ICO. Maximum 5MB.",
        "operationId": "upload_favicon_agency_branding_favicon_post",
        "requestBody": {
          "content": {
            "multipart/form-data": {
              "schema": {
                "$ref": "#/components/schemas/Body_upload_favicon_agency_branding_favicon_post"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LogoUploadResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      },
      "delete": {
        "tags": [
          "Agency Management"
        ],
        "summary": "Delete Favicon",
        "description": "Delete the favicon image and clear favicon_url. Returns refreshed branding.",
        "operationId": "delete_favicon_agency_branding_favicon_delete",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BrandingSettings"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/agency/overview": {
      "get": {
        "tags": [
          "Agency Management"
        ],
        "summary": "Get Agency Overview",
        "description": "Get agency dashboard overview stats.\n\nIncludes aggregated metrics across all sub-accounts, over the agency's\ncurrent Stripe billing period (calendar month without a subscription) so\nthe screen matches the invoice. The response carries the period.",
        "operationId": "get_agency_overview_agency_overview_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgencyOverview"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/agency/invoice-summary": {
      "get": {
        "tags": [
          "Agency Management"
        ],
        "summary": "Get Invoice Summary",
        "description": "Get per-sub-account invoice summary for the current billing period.\n\nReturns voice minutes + revenue, text count + revenue, platform fees,\nand total due for every active sub-account. Sorted by total due descending.",
        "operationId": "get_invoice_summary_agency_invoice_summary_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InvoiceSummaryResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/agency/integrations": {
      "get": {
        "tags": [
          "Agency Management"
        ],
        "summary": "List Agency Integrations",
        "description": "List ALL integrations owned by the agency (GHL, Twilio).\n\nReturns integrations available for assignment to sub-accounts.",
        "operationId": "list_agency_integrations_agency_integrations_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgencyIntegrationsResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/agency/sub-accounts/{sub_account_id}/integrations": {
      "post": {
        "tags": [
          "Agency Management"
        ],
        "summary": "Assign Integrations To Sub Account",
        "description": "Assign multiple integrations to a sub-account.\n\nRules:\n- Maximum 1 GHL integration per sub-account\n- Multiple Twilio/other integrations allowed\n- All integrations must belong to the parent agency",
        "operationId": "assign_integrations_to_sub_account_agency_sub_accounts__sub_account_id__integrations_post",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "sub_account_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Sub Account Id"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AssignIntegrationsRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AssignIntegrationsResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Agency Management"
        ],
        "summary": "Remove All Integrations From Sub Account",
        "description": "Remove ALL integration assignments from a sub-account.",
        "operationId": "remove_all_integrations_from_sub_account_agency_sub_accounts__sub_account_id__integrations_delete",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "sub_account_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Sub Account Id"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Successful Response"
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/agency/sub-accounts/{sub_account_id}/integrations/{integration_id}": {
      "delete": {
        "tags": [
          "Agency Management"
        ],
        "summary": "Remove Integration From Sub Account",
        "description": "Remove a specific integration from a sub-account.",
        "operationId": "remove_integration_from_sub_account_agency_sub_accounts__sub_account_id__integrations__integration_id__delete",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "sub_account_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Sub Account Id"
            }
          },
          {
            "name": "integration_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Integration Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RemoveIntegrationResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/agency/my-integrations": {
      "get": {
        "tags": [
          "Agency Management"
        ],
        "summary": "Get My Integrations",
        "description": "Get all integrations assigned to the current sub-account.\n\nReturns integrations assigned by the parent agency. When an agency is\nimpersonating a sub-account, returns the impersonated sub's assignments.",
        "operationId": "get_my_integrations_agency_my_integrations_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SubAccountIntegrationsResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/agency/my-integration": {
      "get": {
        "tags": [
          "Agency Management"
        ],
        "summary": "Get My Integration Legacy",
        "description": "Legacy endpoint - redirects to /my-integrations.\n\nKept for backward compatibility.",
        "operationId": "get_my_integration_legacy_agency_my_integration_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SubAccountIntegrationsResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/agency/functions": {
      "get": {
        "tags": [
          "Agency Management"
        ],
        "summary": "List All Sub Account Functions",
        "description": "List all custom functions across ALL sub-accounts.\n\nUsed by agencies to select a function to copy/share to another sub-account.\nReturns functions with their source sub-account info.",
        "operationId": "list_all_sub_account_functions_agency_functions_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AllSubAccountFunctionsResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/agency/agents": {
      "get": {
        "tags": [
          "Agency Management"
        ],
        "summary": "List All Sub Account Agents",
        "description": "List all agents across ALL sub-accounts.\n\nUsed by agencies to view, filter, and manage agents across their entire portfolio.\nReturns agents enriched with sub-account name and phone count.",
        "operationId": "list_all_sub_account_agents_agency_agents_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AllSubAccountAgentsResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/agency/agents/{agent_id}/copy": {
      "post": {
        "tags": [
          "Agency Management"
        ],
        "summary": "Copy Agent Between Sub Accounts",
        "description": "Copy an agent from one sub-account to another (agency-only).\n\nVerifies the agency owns both source and target sub-accounts.\nCreates a disabled copy with \" (Copy)\" suffix.\n\nNote: Returns the raw agent dict from the database insert, not AgentResponse.\nAgentResponse has computed fields (phone_count, text_assistants) that aren't\npresent in the raw insert result. The frontend doesn't use this response body\nfor rendering - it invalidates the query cache after a successful copy.",
        "operationId": "copy_agent_between_sub_accounts_agency_agents__agent_id__copy_post",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "agent_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Agent Id"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CopyAgentToSubAccountRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/agency/connect/onboard": {
      "post": {
        "tags": [
          "Agency Management"
        ],
        "summary": "Connect Onboard",
        "description": "Start or continue Stripe onboarding. Returns a fresh Account Link URL.",
        "operationId": "connect_onboard_agency_connect_onboard_post",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "title": "Response Connect Onboard Agency Connect Onboard Post"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/agency/connect/status": {
      "get": {
        "tags": [
          "Agency Management"
        ],
        "summary": "Connect Status",
        "description": "Refresh and return the agency's Stripe Connect status.",
        "operationId": "connect_status_agency_connect_status_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "title": "Response Connect Status Agency Connect Status Get"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/agency/connect/disconnect": {
      "post": {
        "tags": [
          "Agency Management"
        ],
        "summary": "Connect Disconnect",
        "description": "Disconnect client billing. The Stripe account itself is never deleted.",
        "operationId": "connect_disconnect_agency_connect_disconnect_post",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "title": "Response Connect Disconnect Agency Connect Disconnect Post"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/agency/sub-accounts/{sub_account_id}/client-billing": {
      "patch": {
        "tags": [
          "Agency Management"
        ],
        "summary": "Update Client Billing",
        "description": "Opt one sub-account in to (or out of) client billing.",
        "operationId": "update_client_billing_agency_sub_accounts__sub_account_id__client_billing_patch",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "sub_account_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Sub Account Id"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ClientBillingUpdateRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true,
                  "title": "Response Update Client Billing Agency Sub Accounts  Sub Account Id  Client Billing Patch"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/agency/sub-accounts/{sub_account_id}/client-billing/card-link": {
      "post": {
        "tags": [
          "Agency Management"
        ],
        "summary": "Rotate Card Link",
        "description": "Create a new save-card link. The previous link stops working.",
        "operationId": "rotate_card_link_agency_sub_accounts__sub_account_id__client_billing_card_link_post",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "sub_account_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Sub Account Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true,
                  "title": "Response Rotate Card Link Agency Sub Accounts  Sub Account Id  Client Billing Card Link Post"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/agency/sub-accounts/{sub_account_id}/pause": {
      "post": {
        "tags": [
          "Agency Management"
        ],
        "summary": "Pause Sub Account",
        "description": "Pause the sub-account by hand: no calls in or out, no texts, until unpaused.\n\nDrops any unpause override: the agency has taken the pause back.",
        "operationId": "pause_sub_account_agency_sub_accounts__sub_account_id__pause_post",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "sub_account_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Sub Account Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true,
                  "title": "Response Pause Sub Account Agency Sub Accounts  Sub Account Id  Pause Post"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/agency/sub-accounts/{sub_account_id}/unpause": {
      "post": {
        "tags": [
          "Agency Management"
        ],
        "summary": "Unpause Sub Account",
        "description": "Lift any pause on the sub-account, manual or payment_failed.\n\nThe invoices that are failed right now are recorded as the agency's\noverride, so a Stripe retry failure of the same invoice does not pause the\nsub-account again; a different invoice that fails later still pauses it.",
        "operationId": "unpause_sub_account_agency_sub_accounts__sub_account_id__unpause_post",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "sub_account_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Sub Account Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true,
                  "title": "Response Unpause Sub Account Agency Sub Accounts  Sub Account Id  Unpause Post"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/agency/sub-accounts/{sub_account_id}/client-invoices/latest": {
      "get": {
        "tags": [
          "Agency Management"
        ],
        "summary": "Latest Client Invoice",
        "description": "The sub-account's latest client invoice: amount, status, period, link.",
        "operationId": "latest_client_invoice_agency_sub_accounts__sub_account_id__client_invoices_latest_get",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "sub_account_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Sub Account Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true,
                  "title": "Response Latest Client Invoice Agency Sub Accounts  Sub Account Id  Client Invoices Latest Get"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/notifications/settings": {
      "get": {
        "tags": [
          "Notifications"
        ],
        "summary": "Get Notification Settings",
        "description": "Get notification settings for the current tenant.\n\nPer-tenant settings: when impersonating, reads the sub-account's settings.\nReturns default settings if none exist (creating them in the process).",
        "operationId": "get_notification_settings_notifications_settings_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotificationSettingsResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      },
      "patch": {
        "tags": [
          "Notifications"
        ],
        "summary": "Update Notification Settings",
        "description": "Update notification settings for the current tenant.\n\nPer-tenant settings: when impersonating, edits the sub-account's settings.\nOnly provided fields are updated; others remain unchanged.\n\nAn extra notification address equal to the owner's login email is\nrejected: the owner already receives every call email and digest.",
        "operationId": "update_notification_settings_notifications_settings_patch",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NotificationSettingsUpdate"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotificationSettingsResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/notifications/in-app/aggregate": {
      "get": {
        "tags": [
          "Notifications"
        ],
        "summary": "List Aggregate Notifications",
        "description": "List notifications across all sub-accounts (agency owners only).\n\nUses the actual logged-in tenant (not effective) so we always query from\nthe agency owner's perspective, even when in sub-account context.",
        "operationId": "list_aggregate_notifications_notifications_in_app_aggregate_get",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "default": 20,
              "title": "Limit"
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "default": 0,
              "title": "Offset"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotificationListResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/notifications/in-app/aggregate/unread-count": {
      "get": {
        "tags": [
          "Notifications"
        ],
        "summary": "Get Aggregate Unread Count",
        "description": "Get aggregate unread count across all sub-accounts.",
        "operationId": "get_aggregate_unread_count_notifications_in_app_aggregate_unread_count_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnreadCountResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/notifications/in-app": {
      "get": {
        "tags": [
          "Notifications"
        ],
        "summary": "List In App Notifications",
        "description": "List in-app notifications for the current tenant (or sub-account context).",
        "operationId": "list_in_app_notifications_notifications_in_app_get",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "default": 20,
              "title": "Limit"
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "default": 0,
              "title": "Offset"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotificationListResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/notifications/in-app/unread-count": {
      "get": {
        "tags": [
          "Notifications"
        ],
        "summary": "Get Unread Count",
        "description": "Get unread notification count for badge polling.",
        "operationId": "get_unread_count_notifications_in_app_unread_count_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnreadCountResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/notifications/in-app/{notification_id}/read": {
      "patch": {
        "tags": [
          "Notifications"
        ],
        "summary": "Mark Notification Read",
        "description": "Mark a single notification as read.",
        "operationId": "mark_notification_read_notifications_in_app__notification_id__read_patch",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "notification_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Notification Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/notifications/in-app/read-all": {
      "patch": {
        "tags": [
          "Notifications"
        ],
        "summary": "Mark All Notifications Read",
        "description": "Mark all notifications as read.",
        "operationId": "mark_all_notifications_read_notifications_in_app_read_all_patch",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/notifications/in-app/clear": {
      "delete": {
        "tags": [
          "Notifications"
        ],
        "summary": "Clear Read Notifications",
        "description": "Delete all read notifications for the tenant. Keeps unread ones.",
        "operationId": "clear_read_notifications_notifications_in_app_clear_delete",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/notifications/in-app/{notification_id}": {
      "delete": {
        "tags": [
          "Notifications"
        ],
        "summary": "Delete Notification",
        "description": "Delete a single notification.",
        "operationId": "delete_notification_notifications_in_app__notification_id__delete",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "notification_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Notification Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/stats": {
      "get": {
        "tags": [
          "Stats"
        ],
        "summary": "Get Dashboard Stats",
        "description": "Get dashboard statistics for the current tenant.\n\nReturns aggregated stats including:\n- Total calls this month\n- Total minutes used this month\n- Number of active agents\n- Conversion rate (calls that booked appointments)\n- Last 5 recent calls\n- 7-day usage trend",
        "operationId": "get_dashboard_stats_stats_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DashboardStats"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/stats/analytics": {
      "get": {
        "tags": [
          "Stats"
        ],
        "summary": "Get Analytics",
        "description": "Get analytics data for the interactive dashboard.\n\nReturns summary stats, daily call volume trends, status/direction\nbreakdowns, and per-agent performance \u2014 all in one response.",
        "operationId": "get_analytics_stats_analytics_get",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "date_from",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "description": "Start date (YYYY-MM-DD)",
              "title": "Date From"
            },
            "description": "Start date (YYYY-MM-DD)"
          },
          {
            "name": "date_to",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "description": "End date (YYYY-MM-DD)",
              "title": "Date To"
            },
            "description": "End date (YYYY-MM-DD)"
          },
          {
            "name": "agent_id",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "description": "Filter by agent ID",
              "title": "Agent Id"
            },
            "description": "Filter by agent ID"
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AnalyticsResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/appointments": {
      "get": {
        "tags": [
          "Appointments"
        ],
        "summary": "List Appointments",
        "description": "List GHL calendar appointments for the current tenant.\n\nReturns appointments filtered by date range, calendar, and status.\nCancelled and no-show appointments are excluded by default.",
        "operationId": "list_appointments_appointments_get",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "date_from",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "description": "YYYY-MM-DD, default: today",
              "title": "Date From"
            },
            "description": "YYYY-MM-DD, default: today"
          },
          {
            "name": "date_to",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "description": "YYYY-MM-DD, default: +30 days",
              "title": "Date To"
            },
            "description": "YYYY-MM-DD, default: +30 days"
          },
          {
            "name": "calendar_id",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "description": "Filter by calendar ID",
              "title": "Calendar Id"
            },
            "description": "Filter by calendar ID"
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "description": "Filter by status",
              "title": "Status"
            },
            "description": "Filter by status"
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "maximum": 200,
              "minimum": 1,
              "default": 50,
              "title": "Limit"
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0,
              "title": "Offset"
            }
          },
          {
            "name": "integration_id",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "description": "Specific GHL integration",
              "title": "Integration Id"
            },
            "description": "Specific GHL integration"
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AppointmentsResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/appointments/contact/{phone}": {
      "get": {
        "tags": [
          "Appointments"
        ],
        "summary": "List Appointments For Contact",
        "description": "List GHL calendar appointments for a specific contact by phone number.\n\nThe phone number can be in any format (+15551234567, 555-123-4567, etc.).\nFalls back to GHL contact search if phone is not directly on events.",
        "operationId": "list_appointments_for_contact_appointments_contact__phone__get",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "phone",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Phone"
            }
          },
          {
            "name": "date_from",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "description": "YYYY-MM-DD, default: today",
              "title": "Date From"
            },
            "description": "YYYY-MM-DD, default: today"
          },
          {
            "name": "date_to",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "description": "YYYY-MM-DD, default: +30 days",
              "title": "Date To"
            },
            "description": "YYYY-MM-DD, default: +30 days"
          },
          {
            "name": "calendar_id",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "description": "Filter by calendar ID",
              "title": "Calendar Id"
            },
            "description": "Filter by calendar ID"
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "description": "Filter by status",
              "title": "Status"
            },
            "description": "Filter by status"
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "maximum": 200,
              "minimum": 1,
              "default": 50,
              "title": "Limit"
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0,
              "title": "Offset"
            }
          },
          {
            "name": "integration_id",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "description": "Specific GHL integration",
              "title": "Integration Id"
            },
            "description": "Specific GHL integration"
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AppointmentsResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/onboarding/progress": {
      "get": {
        "tags": [
          "Onboarding"
        ],
        "summary": "Get Onboarding Progress",
        "description": "Get current onboarding progress for the tenant.\nCreates a new record if none exists.",
        "operationId": "get_onboarding_progress_onboarding_progress_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OnboardingProgress"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/onboarding/progress/{step}": {
      "put": {
        "tags": [
          "Onboarding"
        ],
        "summary": "Update Onboarding Progress",
        "description": "Update onboarding progress for a specific step.\nMarks the step as complete and advances to the next step.",
        "operationId": "update_onboarding_progress_onboarding_progress__step__put",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "step",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "title": "Step"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StepUpdateRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OnboardingProgress"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/onboarding/skip/{step}": {
      "post": {
        "tags": [
          "Onboarding"
        ],
        "summary": "Skip Onboarding Step",
        "description": "Skip an optional onboarding step.\nOnly steps 2 (CRM), 3 (Phone), and 7 (Complete) can be skipped.",
        "operationId": "skip_onboarding_step_onboarding_skip__step__post",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "step",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "title": "Step"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OnboardingProgress"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/onboarding/navigate/{step}": {
      "put": {
        "tags": [
          "Onboarding"
        ],
        "summary": "Navigate To Step",
        "description": "Navigate to a specific step (back button / sidebar click).\nOnly allows navigating to completed steps or current step.",
        "operationId": "navigate_to_step_onboarding_navigate__step__put",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "step",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "title": "Step"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OnboardingProgress"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/onboarding/reset": {
      "post": {
        "tags": [
          "Onboarding"
        ],
        "summary": "Reset Onboarding Progress",
        "description": "Reset onboarding progress to step 1.\nUseful for testing or allowing users to restart the wizard.",
        "operationId": "reset_onboarding_progress_onboarding_reset_post",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OnboardingProgress"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/setup/status": {
      "get": {
        "tags": [
          "Setup"
        ],
        "summary": "Get Setup Status",
        "description": "Get setup completion status derived from real tenant data.",
        "operationId": "get_setup_status_setup_status_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SetupStatusResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/setup/affiliate/acknowledge": {
      "post": {
        "tags": [
          "Setup"
        ],
        "summary": "Acknowledge Affiliate",
        "description": "Record that the account holder acknowledged the partner program.\n\nThe in-house affiliate program was retired in favour of FirstPromoter and\nthere is no server-side portal credential, so a referral link cannot be\nminted here. This only records that they visited the portal, which is what\ncompletes the Get Started task.",
        "operationId": "acknowledge_affiliate_setup_affiliate_acknowledge_post",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SetupStatusResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/api/public/unsubscribe": {
      "get": {
        "tags": [
          "Public"
        ],
        "summary": "Unsubscribe",
        "description": "One-click unsubscribe from product-update emails. No auth required - the\nsigned token is the authorization. Idempotent. Returns a human-readable page\n(email clients / scanners follow the link): 200 once the opt-out is saved, 400\nfor a bad token, 503 if the opt-out could not be saved.",
        "operationId": "unsubscribe_api_public_unsubscribe_get",
        "parameters": [
          {
            "name": "email",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Recipient email to unsubscribe",
              "title": "Email"
            },
            "description": "Recipient email to unsubscribe"
          },
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "description": "HMAC signature validating the email",
              "title": "Token"
            },
            "description": "HMAC signature validating the email"
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/api/public/branding": {
      "get": {
        "tags": [
          "Public"
        ],
        "summary": "Get Branding By Domain",
        "description": "Fetch public branding info for a custom domain. No auth required.",
        "operationId": "get_branding_by_domain_api_public_branding_get",
        "parameters": [
          {
            "name": "domain",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Custom domain to look up branding for",
              "title": "Domain"
            },
            "description": "Custom domain to look up branding for"
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicBrandingResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/api/public/client-card/{token}": {
      "get": {
        "tags": [
          "Public"
        ],
        "summary": "Client Card Link",
        "description": "Public save-card link for an agency's client. No login: the token is the\nauthorization. Redirects (303) to Stripe Checkout in setup mode, created on\nthe agency's own connected account so the page shows the agency's name.\n\nEvery failure (feature off, unknown or rotated token, sub-account opted out,\nagency disconnected or charges disabled, mode mismatch) is the same 404.",
        "operationId": "client_card_link_api_public_client_card__token__get",
        "parameters": [
          {
            "name": "token",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Token"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/share/{slug}": {
      "get": {
        "tags": [
          "Public Share"
        ],
        "summary": "Get Public Agent",
        "description": "Public endpoint: Get agent info for the demo page. No auth required.",
        "operationId": "get_public_agent_share__slug__get",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Slug"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicAgentResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/demos/": {
      "get": {
        "tags": [
          "Demos"
        ],
        "summary": "List Demos",
        "description": "List all demo configs for the current tenant.",
        "operationId": "list_demos_demos__get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/DemoConfigListItem"
                  },
                  "type": "array",
                  "title": "Response List Demos Demos  Get"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      },
      "post": {
        "tags": [
          "Demos"
        ],
        "summary": "Create Demo",
        "description": "Create a new demo config.",
        "operationId": "create_demo_demos__post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DemoConfigCreate"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DemoConfigResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/demos/templates": {
      "get": {
        "tags": [
          "Demos"
        ],
        "summary": "Get Templates",
        "description": "Get all industry demo templates.",
        "operationId": "get_templates_demos_templates_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/demos/templates/{industry}/{channel}": {
      "get": {
        "tags": [
          "Demos"
        ],
        "summary": "Get Template",
        "description": "Get a specific industry/channel demo template.",
        "operationId": "get_template_demos_templates__industry___channel__get",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "industry",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Industry"
            }
          },
          {
            "name": "channel",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Channel"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/demos/import-from-url/stream": {
      "get": {
        "tags": [
          "Demos"
        ],
        "summary": "Import From Url Stream",
        "description": "Import demo configuration from a website URL with streaming progress updates.\n\nUses Server-Sent Events (SSE) to stream progress in real-time:\n- Step updates: \"discovering\", \"scraping\", \"extracting\", \"generating\"\n- Progress: current/total for each step\n- Detail: what's currently being processed\n\nFinal event contains the complete ImportFromUrlResponse.",
        "operationId": "import_from_url_stream_demos_import_from_url_stream_get",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "url",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Url"
            }
          },
          {
            "name": "channel",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Channel"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/demos/import-from-url": {
      "post": {
        "tags": [
          "Demos"
        ],
        "summary": "Import From Url",
        "description": "Import demo configuration from a website URL (non-streaming fallback).\n\nScrapes the provided URL, extracts business information using AI,\nand generates personalized demo text (headline, summary, CTA).\n\nReturns all fields needed to pre-fill the demo creation wizard.\n\nNote: Prefer /import-from-url/stream for real-time progress updates.",
        "operationId": "import_from_url_demos_import_from_url_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ImportFromUrlRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/demos/webhook-test": {
      "post": {
        "tags": [
          "Demos"
        ],
        "summary": "Test Webhook Url",
        "description": "Test any webhook URL by sending a sample payload. No demo ID needed.",
        "operationId": "test_webhook_url_demos_webhook_test_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookUrlTestRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/demos/{demo_id}": {
      "get": {
        "tags": [
          "Demos"
        ],
        "summary": "Get Demo",
        "description": "Get a single demo config.",
        "operationId": "get_demo_demos__demo_id__get",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "demo_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Demo Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DemoConfigResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "Demos"
        ],
        "summary": "Update Demo",
        "description": "Update a demo config.\n\nTurning a demo OFF (``is_active: false`` and nothing else) is open to every\nplan. Any other change needs the Demo Suite plan feature.",
        "operationId": "update_demo_demos__demo_id__patch",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "demo_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Demo Id"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DemoConfigUpdate"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DemoConfigResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Demos"
        ],
        "summary": "Delete Demo",
        "description": "Delete a demo config.",
        "operationId": "delete_demo_demos__demo_id__delete",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "demo_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Demo Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/demos/{demo_id}/duplicate": {
      "post": {
        "tags": [
          "Demos"
        ],
        "summary": "Duplicate Demo",
        "description": "Clone a demo config.",
        "operationId": "duplicate_demo_demos__demo_id__duplicate_post",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "demo_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Demo Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DemoConfigResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/demos/{demo_id}/upload-image": {
      "post": {
        "tags": [
          "Demos"
        ],
        "summary": "Upload Demo Image",
        "description": "Upload an image for a demo config (ad creative, logo, avatar, etc.).",
        "operationId": "upload_demo_image_demos__demo_id__upload_image_post",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "demo_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Demo Id"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "$ref": "#/components/schemas/Body_upload_demo_image_demos__demo_id__upload_image_post"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/demos/{demo_id}/analytics": {
      "get": {
        "tags": [
          "Demos"
        ],
        "summary": "Get Demo Analytics",
        "description": "Get analytics for a demo config.",
        "operationId": "get_demo_analytics_demos__demo_id__analytics_get",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "demo_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Demo Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/demos/{demo_id}/webhook-test": {
      "post": {
        "tags": [
          "Demos"
        ],
        "summary": "Test Demo Webhook",
        "description": "Send a test payload to the demo's webhook URL.",
        "operationId": "test_demo_webhook_demos__demo_id__webhook_test_post",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "demo_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Demo Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/d/{slug}": {
      "get": {
        "tags": [
          "Public Demos"
        ],
        "summary": "Get Public Demo",
        "description": "Public endpoint: Get demo config for the demo page. No auth required.",
        "operationId": "get_public_demo_d__slug__get",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Slug"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicDemoResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/d/{slug}/event": {
      "post": {
        "tags": [
          "Public Demos"
        ],
        "summary": "Track Demo Event",
        "description": "Public endpoint: Track a demo event (view, call, form submit).",
        "operationId": "track_demo_event_d__slug__event_post",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Slug"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DemoEventCreate"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/d/{slug}/chat": {
      "post": {
        "tags": [
          "Public Demos"
        ],
        "summary": "Public Demo Chat",
        "description": "Public text chat endpoint for demo pages.\nUses the agent's system prompt + tools to generate AI text responses.\nNo auth required - authenticates via active demo config slug.",
        "operationId": "public_demo_chat_d__slug__chat_post",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Slug"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DemoChatRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DemoChatResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/d/showcase/{slug}": {
      "get": {
        "tags": [
          "Public Demos"
        ],
        "summary": "Get Showcase",
        "description": "Public endpoint: Get all active demos for a showcase page.\nThe slug here is any demo slug - we find the agent and return all demos for it.",
        "operationId": "get_showcase_d_showcase__slug__get",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Slug"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/d/{slug}/look": {
      "get": {
        "tags": [
          "Public Demos"
        ],
        "summary": "Get Public Demo Look",
        "description": "Public endpoint (DAN-613): the demo's saved orb color and position, read by\nthe hosted leadlock-voice.js so an agency sets the look once.\n\nReturns ONLY {\"color\", \"position\"}. Follows the DAN-472 Origin allowlist\nfrom the same row: a refused Origin gets 403 with no CORS header; with no\nallowlist the answer is readable from any site. Read-only, cached 60s\n(browser and server; the server read is capped at 2s, see public_look).",
        "operationId": "get_public_demo_look_d__slug__look_get",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Slug"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicDemoLookResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/voice-samples/gemini/{voice}.mp3": {
      "get": {
        "tags": [
          "Voice Samples",
          "Voice Samples"
        ],
        "summary": "Get Gemini Voice Sample",
        "description": "Serve pre-generated Gemini voice sample MP3.",
        "operationId": "get_gemini_voice_sample_voice_samples_gemini__voice__mp3_get",
        "parameters": [
          {
            "name": "voice",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Voice"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/voice-samples/openai-live/{voice}.mp3": {
      "get": {
        "tags": [
          "Voice Samples",
          "Voice Samples"
        ],
        "summary": "Get Openai Live Voice Sample",
        "description": "Serve pre-generated GPT-Live voice sample MP3.\n\nVoices are validated against OPENAI_LIVE_VOICES in live_client.py rather than\na second hardcoded list here \u2014 the roster already lives in three places\n(that constant, the frontend picker, the migration default) and a fourth\nwould drift.\n\nSamples are generated by scripts/generate_openai_live_voice_samples.py, which\nspeaks a fixed line through a real gpt-live-1 session per voice. They are not\nsynthesised from some other TTS engine: these 12 voices exist only on the Live\nAPI, so a sample from anywhere else would be a different voice.",
        "operationId": "get_openai_live_voice_sample_voice_samples_openai_live__voice__mp3_get",
        "parameters": [
          {
            "name": "voice",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Voice"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/voice-samples/openai/{voice}.mp3": {
      "get": {
        "tags": [
          "Voice Samples",
          "Voice Samples"
        ],
        "summary": "Get Openai Voice Sample",
        "description": "Serve pre-generated OpenAI voice sample MP3.",
        "operationId": "get_openai_voice_sample_voice_samples_openai__voice__mp3_get",
        "parameters": [
          {
            "name": "voice",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Voice"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/voice-samples/premium/{voice}.mp3": {
      "get": {
        "tags": [
          "Voice Samples",
          "Voice Samples"
        ],
        "summary": "Get Premium Voice Sample",
        "description": "Serve pre-generated ElevenLabs voice sample MP3.",
        "operationId": "get_premium_voice_sample_voice_samples_premium__voice__mp3_get",
        "parameters": [
          {
            "name": "voice",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Voice"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/voice-samples/{voice}.mp3": {
      "get": {
        "tags": [
          "Voice Samples",
          "Voice Samples"
        ],
        "summary": "Get Voice Sample",
        "description": "Serve pre-generated Standard voice sample MP3.",
        "operationId": "get_voice_sample_voice_samples__voice__mp3_get",
        "parameters": [
          {
            "name": "voice",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Voice"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/voice-samples/elevenlabs/voices": {
      "get": {
        "tags": [
          "Voice Samples",
          "Voice Samples"
        ],
        "summary": "List Elevenlabs Voices",
        "description": "Live ElevenLabs voice list, replacing the hardcoded frontend array.\n\nAUTHENTICATED deliberately, unlike the static sample routes above: the\nworkspace contains cloned voices named after real people.\n\nShaped to match what the picker already renders ({id, name, gender,\ndescription}) so the frontend swaps a constant for a fetch and nothing else\nchanges. `preview_url` comes straight from ElevenLabs, which is what lets us\nretire the self-hosted MP3s.\n\nCached in-process: the catalogue changes rarely and the picker mounts on\nevery agent-form open.",
        "operationId": "list_elevenlabs_voices_voice_samples_elevenlabs_voices_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "title": "Response List Elevenlabs Voices Voice Samples Elevenlabs Voices Get"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/voice-samples/elevenlabs/models": {
      "get": {
        "tags": [
          "Voice Samples",
          "Voice Samples"
        ],
        "summary": "List Elevenlabs Models",
        "description": "The curated ElevenLabs LLM list, grouped as the picker renders it.\n\nExists so the list is written ONCE. It used to be a literal in\nPremiumVoiceSelector.tsx mirroring the literal in agents/defaults.py, kept\nhonest by a parity test \u2014 which caught drift but could not prevent it. The\ntwo halves deploy as separate Render services, so on 2026-08-14 the static\nsite shipped a widened list ~10 minutes before the backend knew about it and\nthe picker briefly offered models the API would have 422'd.\n\nStatic data, no provider call: safe to serve from the constant and cache\nhard on the client.",
        "operationId": "list_elevenlabs_models_voice_samples_elevenlabs_models_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "title": "Response List Elevenlabs Models Voice Samples Elevenlabs Models Get"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/voice-samples/elevenlabs/llm-prices": {
      "get": {
        "tags": [
          "Voice Samples",
          "Voice Samples"
        ],
        "summary": "Get Elevenlabs Llm Prices",
        "description": "Real $/min per LLM at this agent's own prompt length.\n\nReplaces the prices that used to be baked into the picker's display strings.\nThose were wrong for 13 of 23 models because a single number cannot describe\na cost that scales with prompt length \u2014 see client.calculate_llm_usage.\n\nOnly the CURATED models are returned. Pricing the ones we no longer offer\nwould invite someone to wire them back up.\n\nNever fails the form: on a provider error this serves stale, then the\nmeasured median-prompt fallback. `estimated` tells the UI which it got.",
        "operationId": "get_elevenlabs_llm_prices_voice_samples_elevenlabs_llm_prices_get",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "prompt_length",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "default": 0,
              "title": "Prompt Length"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true,
                  "title": "Response Get Elevenlabs Llm Prices Voice Samples Elevenlabs Llm Prices Get"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/voice-samples/": {
      "get": {
        "tags": [
          "Voice Samples",
          "Voice Samples"
        ],
        "summary": "List Voice Samples",
        "description": "List all available voice samples.\n\nReturns:\n    List of available voice names with URLs",
        "operationId": "list_voice_samples_voice_samples__get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          }
        }
      }
    },
    "/contacts/": {
      "get": {
        "tags": [
          "Contacts",
          "Contacts"
        ],
        "summary": "List Contacts",
        "description": "List GHL contacts with call statistics.\n\nReturns paginated list of contacts enriched with:\n- Total call count\n- Last call date\n\nUses cursor-based pagination (GHL requirement). Pass BOTH `start_after_id` and\n`start_after` from the previous response to get the next page.\n\nFor tenants with multiple GHL accounts, use integration_id to specify which one.\nUse has_calls_only=true to filter to only contacts that have AI calls.",
        "operationId": "list_contacts_contacts__get",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "maximum": 100,
              "minimum": 1,
              "default": 50,
              "title": "Limit"
            }
          },
          {
            "name": "search",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Search"
            }
          },
          {
            "name": "integration_id",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "description": "Specific GHL integration ID for multi-account tenants",
              "title": "Integration Id"
            },
            "description": "Specific GHL integration ID for multi-account tenants"
          },
          {
            "name": "has_calls_only",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean",
              "description": "Only show contacts with AI calls",
              "default": false,
              "title": "Has Calls Only"
            },
            "description": "Only show contacts with AI calls"
          },
          {
            "name": "enrich",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean",
              "description": "Enrich with call stats (set false for fast search)",
              "default": true,
              "title": "Enrich"
            },
            "description": "Enrich with call stats (set false for fast search)"
          },
          {
            "name": "start_after_id",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "description": "Cursor for pagination - contact ID from previous page's next_cursor",
              "title": "Start After Id"
            },
            "description": "Cursor for pagination - contact ID from previous page's next_cursor"
          },
          {
            "name": "start_after",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "integer"
                },
                {
                  "type": "null"
                }
              ],
              "description": "Cursor timestamp from previous page's next_cursor_timestamp",
              "title": "Start After"
            },
            "description": "Cursor timestamp from previous page's next_cursor_timestamp"
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ContactListResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/contacts/with-calls": {
      "get": {
        "tags": [
          "Contacts",
          "Contacts"
        ],
        "summary": "List Contacts With Calls",
        "description": "List only contacts that have AI call history.\n\nUses inverted data flow: queries call_logs first, then fetches GHL data.\nThis ensures ALL contacts with calls are found, not limited by GHL pagination.\n\nSupports server-side sorting and filtering:\n- sort_by: name, phone, email, company, calls, last_call\n- sort_dir: asc, desc\n- filter_phone/email/company: blank, not_blank",
        "operationId": "list_contacts_with_calls_contacts_with_calls_get",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "maximum": 100,
              "minimum": 1,
              "default": 50,
              "title": "Limit"
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0,
              "title": "Offset"
            }
          },
          {
            "name": "integration_id",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "description": "Specific GHL integration ID for multi-account tenants",
              "title": "Integration Id"
            },
            "description": "Specific GHL integration ID for multi-account tenants"
          },
          {
            "name": "sort_by",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "description": "Sort by: name, phone, email, company, calls, last_call",
              "title": "Sort By"
            },
            "description": "Sort by: name, phone, email, company, calls, last_call"
          },
          {
            "name": "sort_dir",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "description": "Sort direction: asc or desc",
              "title": "Sort Dir"
            },
            "description": "Sort direction: asc or desc"
          },
          {
            "name": "filter_phone",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "description": "Filter phone: blank or not_blank",
              "title": "Filter Phone"
            },
            "description": "Filter phone: blank or not_blank"
          },
          {
            "name": "filter_email",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "description": "Filter email: blank or not_blank",
              "title": "Filter Email"
            },
            "description": "Filter email: blank or not_blank"
          },
          {
            "name": "filter_company",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "description": "Filter company: blank or not_blank",
              "title": "Filter Company"
            },
            "description": "Filter company: blank or not_blank"
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ContactListResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/contacts/{phone}": {
      "get": {
        "tags": [
          "Contacts",
          "Contacts"
        ],
        "summary": "Get Contact Detail",
        "description": "Get contact details with full call history.\n\nArgs:\n    phone: Phone number (URL-encoded if contains special chars)\n    enrich: Set to \"full\" for pipeline, custom fields, and appointment enrichment",
        "operationId": "get_contact_detail_contacts__phone__get",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "phone",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Phone"
            }
          },
          {
            "name": "enrich",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "description": "Set to 'full' for enriched contact data",
              "title": "Enrich"
            },
            "description": "Set to 'full' for enriched contact data"
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/ContactDetailResponse"
                    },
                    {
                      "$ref": "#/components/schemas/EnrichedContactDetailResponse"
                    }
                  ],
                  "title": "Response Get Contact Detail Contacts  Phone  Get"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "Contacts",
          "Contacts"
        ],
        "summary": "Patch Contact",
        "description": "Update a GHL contact: add/remove tags, update custom fields, update pipeline stage.\n\nEach field is independently optional \u2014 partial success is OK.",
        "operationId": "patch_contact_contacts__phone__patch",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "phone",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Phone"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ContactPatchRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ContactPatchResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/contacts/{phone}/conversations": {
      "get": {
        "tags": [
          "Contacts",
          "Contacts"
        ],
        "summary": "Get Conversation Timeline",
        "description": "Get merged call + SMS conversation timeline for a contact.\n\nReturns chronological list merging call_logs and text_messages.\nGracefully degrades to voice-only if GHL lookup fails (sms_included=false).\nNever returns 404 \u2014 empty timeline is valid.",
        "operationId": "get_conversation_timeline_contacts__phone__conversations_get",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "phone",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Phone"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "maximum": 200,
              "minimum": 1,
              "default": 50,
              "title": "Limit"
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0,
              "title": "Offset"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConversationTimelineResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/contacts/{phone}/notes": {
      "post": {
        "tags": [
          "Contacts",
          "Contacts"
        ],
        "summary": "Create Note",
        "description": "Create a note on a GHL contact.",
        "operationId": "create_note_contacts__phone__notes_post",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "phone",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Phone"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NoteCreateRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NoteResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "Contacts",
          "Contacts"
        ],
        "summary": "List Notes",
        "description": "List notes for a GHL contact.",
        "operationId": "list_notes_contacts__phone__notes_get",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "phone",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Phone"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotesListResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/test/active-sessions": {
      "get": {
        "tags": [
          "WebSocket"
        ],
        "summary": "List Active Sessions",
        "description": "List active voice sessions (for testing).",
        "operationId": "list_active_sessions_test_active_sessions_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "title": "Response List Active Sessions Test Active Sessions Get"
                }
              }
            }
          }
        }
      }
    },
    "/test/kill-xai/{call_sid}": {
      "post": {
        "tags": [
          "WebSocket"
        ],
        "summary": "Kill Xai Connection",
        "description": "Kill xAI connection to test graceful degradation.",
        "operationId": "kill_xai_connection_test_kill_xai__call_sid__post",
        "parameters": [
          {
            "name": "call_sid",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Call Sid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true,
                  "title": "Response Kill Xai Connection Test Kill Xai  Call Sid  Post"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/issues/": {
      "post": {
        "tags": [
          "Issues"
        ],
        "summary": "Create Issue",
        "description": "Submit an issue report with optional screenshot.",
        "operationId": "create_issue_issues__post",
        "requestBody": {
          "content": {
            "multipart/form-data": {
              "schema": {
                "$ref": "#/components/schemas/Body_create_issue_issues__post"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "title": "Response Create Issue Issues  Post"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/support/contact": {
      "post": {
        "tags": [
          "Support"
        ],
        "summary": "Contact Support",
        "description": "Send a message to Leadlock support from inside the app.\n\nThe message is emailed to the Leadlock support inbox with Reply-To set to\nthe signed-in user's email, so support replies go straight to the user.\nSubject is 1-200 characters and message is 1-5000 characters (surrounding\nwhitespace is trimmed). Limited to 5 messages per user per hour (429).\nReturns 502 if the email could not be sent; in that case, email\nsupport@leadlock.ai directly.",
        "operationId": "contact_support_support_contact_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ContactSupportRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ContactSupportResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/scheduled-calls": {
      "get": {
        "tags": [
          "Scheduled Calls",
          "Scheduled Calls"
        ],
        "summary": "List Scheduled Calls",
        "description": "List scheduled calls for the current tenant.\n\nSupports filtering by status, agent, and date range.\nReturns soonest calls first.",
        "operationId": "list_scheduled_calls_scheduled_calls_get",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "maximum": 100,
              "minimum": 1,
              "default": 50,
              "title": "Limit"
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0,
              "title": "Offset"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "description": "Filter by status: pending, dialing, completed, failed, cancelled",
              "title": "Status"
            },
            "description": "Filter by status: pending, dialing, completed, failed, cancelled"
          },
          {
            "name": "agent_id",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "format": "uuid"
                },
                {
                  "type": "null"
                }
              ],
              "description": "Filter by agent",
              "title": "Agent Id"
            },
            "description": "Filter by agent"
          },
          {
            "name": "start_date",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "format": "date-time"
                },
                {
                  "type": "null"
                }
              ],
              "description": "Filter by scheduled_for >= start_date",
              "title": "Start Date"
            },
            "description": "Filter by scheduled_for >= start_date"
          },
          {
            "name": "end_date",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "format": "date-time"
                },
                {
                  "type": "null"
                }
              ],
              "description": "Filter by scheduled_for <= end_date",
              "title": "End Date"
            },
            "description": "Filter by scheduled_for <= end_date"
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScheduledCallListResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Scheduled Calls",
          "Scheduled Calls"
        ],
        "summary": "Create Scheduled Call",
        "description": "Create a new scheduled call (manual scheduling from UI).\n\nFor AI-driven scheduling, use the schedule_callback function during a call.",
        "operationId": "create_scheduled_call_scheduled_calls_post",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ScheduledCallCreate"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScheduledCallResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/scheduled-calls/{scheduled_call_id}": {
      "get": {
        "tags": [
          "Scheduled Calls",
          "Scheduled Calls"
        ],
        "summary": "Get Scheduled Call",
        "description": "Get a specific scheduled call by ID.",
        "operationId": "get_scheduled_call_scheduled_calls__scheduled_call_id__get",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "scheduled_call_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Scheduled Call Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScheduledCallResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "Scheduled Calls",
          "Scheduled Calls"
        ],
        "summary": "Update Scheduled Call",
        "description": "Update a scheduled call.\n\nOnly pending calls can be updated.",
        "operationId": "update_scheduled_call_scheduled_calls__scheduled_call_id__patch",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "scheduled_call_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Scheduled Call Id"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ScheduledCallUpdate"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScheduledCallResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Scheduled Calls",
          "Scheduled Calls"
        ],
        "summary": "Delete Scheduled Call",
        "description": "Delete a scheduled call.",
        "operationId": "delete_scheduled_call_scheduled_calls__scheduled_call_id__delete",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "scheduled_call_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Scheduled Call Id"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Successful Response"
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/scheduled-calls/{scheduled_call_id}/cancel": {
      "post": {
        "tags": [
          "Scheduled Calls",
          "Scheduled Calls"
        ],
        "summary": "Cancel Scheduled Call",
        "description": "Cancel a pending scheduled call.",
        "operationId": "cancel_scheduled_call_scheduled_calls__scheduled_call_id__cancel_post",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "scheduled_call_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Scheduled Call Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScheduledCallResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/scheduled-calls/{scheduled_call_id}/trigger": {
      "post": {
        "tags": [
          "Scheduled Calls",
          "Scheduled Calls"
        ],
        "summary": "Trigger Scheduled Call",
        "description": "Immediately trigger a pending scheduled call.\n\nBypasses the scheduler wait and dials right away.",
        "operationId": "trigger_scheduled_call_scheduled_calls__scheduled_call_id__trigger_post",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "scheduled_call_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Scheduled Call Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScheduledCallResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/scheduled-calls/{scheduled_call_id}/retry": {
      "post": {
        "tags": [
          "Scheduled Calls",
          "Scheduled Calls"
        ],
        "summary": "Retry Scheduled Call",
        "description": "Retry a failed scheduled call.\n\nIf no new time is provided, schedules for 5 minutes from now.",
        "operationId": "retry_scheduled_call_scheduled_calls__scheduled_call_id__retry_post",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "scheduled_call_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Scheduled Call Id"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ScheduledCallRetry"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScheduledCallResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/testing/byok-keys": {
      "get": {
        "tags": [
          "Testing & Intelligence",
          "Testing & Intelligence"
        ],
        "summary": "Get Byok Keys",
        "description": "List all BYOK keys for the current tenant (no secrets returned).",
        "operationId": "get_byok_keys_testing_byok_keys_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      },
      "post": {
        "tags": [
          "Testing & Intelligence",
          "Testing & Intelligence"
        ],
        "summary": "Create Key",
        "description": "Add a new BYOK key. Validates the key before storing.",
        "operationId": "create_key_testing_byok_keys_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BYOKKeyCreate"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/testing/byok-keys/{provider}": {
      "delete": {
        "tags": [
          "Testing & Intelligence",
          "Testing & Intelligence"
        ],
        "summary": "Remove Key",
        "description": "Delete a BYOK key.",
        "operationId": "remove_key_testing_byok_keys__provider__delete",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "provider",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Provider"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/testing/scenarios": {
      "get": {
        "tags": [
          "Testing & Intelligence",
          "Testing & Intelligence"
        ],
        "summary": "Get Scenarios",
        "description": "List available pre-built scenarios.",
        "operationId": "get_scenarios_testing_scenarios_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/testing/criteria-library": {
      "get": {
        "tags": [
          "Testing & Intelligence",
          "Testing & Intelligence"
        ],
        "summary": "Get Criteria Library",
        "description": "Return the full criteria library with categories. Static data, cacheable.",
        "operationId": "get_criteria_library_testing_criteria_library_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/testing/agents/{agent_id}/suggested-criteria": {
      "get": {
        "tags": [
          "Testing & Intelligence",
          "Testing & Intelligence"
        ],
        "summary": "Get Agent Suggested Criteria",
        "description": "Return criteria relevant to this agent's enabled tools and feature flags.",
        "operationId": "get_agent_suggested_criteria_testing_agents__agent_id__suggested_criteria_get",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "agent_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Agent Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/testing/generate-scenario": {
      "post": {
        "tags": [
          "Testing & Intelligence",
          "Testing & Intelligence"
        ],
        "summary": "Generate Scenario",
        "description": "Generate a simulation scenario from a natural language description using AI.",
        "operationId": "generate_scenario_testing_generate_scenario_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/GenerateScenarioRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/testing/agents/{agent_id}/simulate": {
      "post": {
        "tags": [
          "Testing & Intelligence",
          "Testing & Intelligence"
        ],
        "summary": "Run Simulation",
        "description": "Run a bot-vs-bot simulation against an agent. Returns immediately with running status.",
        "operationId": "run_simulation_testing_agents__agent_id__simulate_post",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "agent_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Agent Id"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ScenarioRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/testing/agents/{agent_id}/simulations": {
      "get": {
        "tags": [
          "Testing & Intelligence",
          "Testing & Intelligence"
        ],
        "summary": "Get Agent Simulations",
        "description": "List simulation runs for an agent.",
        "operationId": "get_agent_simulations_testing_agents__agent_id__simulations_get",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "agent_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Agent Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/testing/simulations/{run_id}": {
      "get": {
        "tags": [
          "Testing & Intelligence",
          "Testing & Intelligence"
        ],
        "summary": "Get Simulation",
        "description": "Get a simulation run by ID (poll for completion).",
        "operationId": "get_simulation_testing_simulations__run_id__get",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "run_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Run Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/testing/agents/{agent_id}/analyze-calls": {
      "post": {
        "tags": [
          "Testing & Intelligence",
          "Testing & Intelligence"
        ],
        "summary": "Analyze Calls",
        "description": "Analyze one or more call transcripts with custom criteria.",
        "operationId": "analyze_calls_testing_agents__agent_id__analyze_calls_post",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "agent_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Agent Id"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AnalyzeCallsRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/testing/agents/{agent_id}/analyze-calls-stream": {
      "post": {
        "tags": [
          "Testing & Intelligence",
          "Testing & Intelligence"
        ],
        "summary": "Analyze Calls Stream",
        "description": "Analyze call transcripts with SSE streaming progress.\n\nReturns Server-Sent Events:\n- progress: {current, total, call_id, status}\n- call_result: per-call analysis result\n- call_error: per-call error\n- complete: final summary\n- error: fatal error",
        "operationId": "analyze_calls_stream_testing_agents__agent_id__analyze_calls_stream_post",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "agent_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Agent Id"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AnalyzeCallsRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/testing/agents/{agent_id}/suggest-prompt": {
      "post": {
        "tags": [
          "Testing & Intelligence",
          "Testing & Intelligence"
        ],
        "summary": "Suggest Prompt",
        "description": "Generate prompt improvement suggestions from analysis/simulation results.",
        "operationId": "suggest_prompt_testing_agents__agent_id__suggest_prompt_post",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "agent_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Agent Id"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SuggestPromptRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/testing/agents/{agent_id}/apply-prompt": {
      "post": {
        "tags": [
          "Testing & Intelligence",
          "Testing & Intelligence"
        ],
        "summary": "Apply Prompt",
        "description": "Apply a prompt suggestion to the agent's system prompt.",
        "operationId": "apply_prompt_testing_agents__agent_id__apply_prompt_post",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "agent_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Agent Id"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ApplyPromptRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/testing/agents/{agent_id}/rewrite-prompt": {
      "post": {
        "tags": [
          "Testing & Intelligence",
          "Testing & Intelligence"
        ],
        "summary": "Rewrite Prompt",
        "description": "Holistically rewrite the agent's prompt incorporating all suggestions. Returns preview.",
        "operationId": "rewrite_prompt_testing_agents__agent_id__rewrite_prompt_post",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "agent_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Agent Id"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RewritePromptRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/testing/agents/{agent_id}/save-rewritten-prompt": {
      "post": {
        "tags": [
          "Testing & Intelligence",
          "Testing & Intelligence"
        ],
        "summary": "Save Rewritten Prompt",
        "description": "Save an approved rewritten prompt to the agent.",
        "operationId": "save_rewritten_prompt_testing_agents__agent_id__save_rewritten_prompt_post",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "agent_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Agent Id"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SaveRewrittenPromptRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/testing/agents/{agent_id}/analysis-history": {
      "get": {
        "tags": [
          "Testing & Intelligence",
          "Testing & Intelligence"
        ],
        "summary": "Get Analysis History",
        "description": "Get historical diagnosis scores for an agent, for trend charting.",
        "operationId": "get_analysis_history_testing_agents__agent_id__analysis_history_get",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "agent_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Agent Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/testing/agents/{agent_id}/coaching-plan": {
      "post": {
        "tags": [
          "Testing & Intelligence",
          "Testing & Intelligence"
        ],
        "summary": "Generate Coaching Plan",
        "description": "Generate a coaching plan from diagnosis findings.",
        "operationId": "generate_coaching_plan_testing_agents__agent_id__coaching_plan_post",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "agent_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Agent Id"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true,
                "title": "Request"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/tools/scrape-website": {
      "post": {
        "tags": [
          "External Tools"
        ],
        "summary": "Scrape Website Endpoint",
        "description": "Scrape a website and extract structured business information.\n\nUses Jina Reader for scraping and xAI for AI extraction. Bounded to respond\nbefore webhook clients (e.g. GHL) hang up \u2014 degrades to homepage-only / raw\ndescription rather than exceeding the time budget.",
        "operationId": "scrape_website_endpoint_tools_scrape_website_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ScrapeWebsiteRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScrapeWebsiteResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/tools/screenshot": {
      "post": {
        "tags": [
          "External Tools"
        ],
        "summary": "Screenshot Endpoint",
        "description": "Capture a website screenshot and upload to storage.\n\nUses ScreenshotOne API for capture and Supabase Storage for hosting.",
        "operationId": "screenshot_endpoint_tools_screenshot_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ScreenshotRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScreenshotResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/documents": {
      "get": {
        "tags": [
          "Documents",
          "Documents"
        ],
        "summary": "List Documents",
        "description": "List all documents for the current tenant.\n\nFor agencies: requires sub-account context (X-Sub-Account-Id header).\nFor direct tenants: returns their documents.",
        "operationId": "list_documents_documents_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DocumentListResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      },
      "post": {
        "tags": [
          "Documents",
          "Documents"
        ],
        "summary": "Upload Document",
        "description": "Upload a document to the knowledge base.\n\nSupports 100+ file types (validated by xAI). Max 48MB.\n\nFor agencies: requires sub-account context (X-Sub-Account-Id header).\nFor direct tenants: uploads to their collection.",
        "operationId": "upload_document_documents_post",
        "requestBody": {
          "content": {
            "multipart/form-data": {
              "schema": {
                "$ref": "#/components/schemas/Body_upload_document_documents_post"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DocumentResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/documents/{document_id}": {
      "delete": {
        "tags": [
          "Documents",
          "Documents"
        ],
        "summary": "Delete Document",
        "description": "Delete a document from the knowledge base.\n\nFor agencies: requires sub-account context (X-Sub-Account-Id header).\nFor direct tenants: deletes from their collection.",
        "operationId": "delete_document_documents__document_id__delete",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "document_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Document Id"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Successful Response"
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/documents/stats": {
      "get": {
        "tags": [
          "Documents",
          "Documents"
        ],
        "summary": "Get Stats",
        "description": "Get collection statistics for the current tenant.\n\nReturns document counts, total size, and status breakdown.",
        "operationId": "get_stats_documents_stats_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CollectionStatsResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/documents/search": {
      "post": {
        "tags": [
          "Documents",
          "Documents"
        ],
        "summary": "Search Documents",
        "description": "Search documents in the knowledge base.\n\nFor agencies: requires sub-account context (X-Sub-Account-Id header).\nFor direct tenants: searches their collection.",
        "operationId": "search_documents_documents_search_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SearchRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SearchResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/knowledge-bases": {
      "get": {
        "tags": [
          "Knowledge Bases",
          "Knowledge Bases"
        ],
        "summary": "List Knowledge Bases",
        "description": "List all Knowledge Bases for the current tenant.\n\nFor agencies: requires sub-account context (X-Sub-Account-Id header).\nFor direct tenants: returns their Knowledge Bases.",
        "operationId": "list_knowledge_bases_knowledge_bases_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KnowledgeBaseListResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      },
      "post": {
        "tags": [
          "Knowledge Bases",
          "Knowledge Bases"
        ],
        "summary": "Create Knowledge Base",
        "description": "Create a new Knowledge Base.\n\nCreates an xAI collection for document storage.",
        "operationId": "create_knowledge_base_knowledge_bases_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/KnowledgeBaseCreate"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KnowledgeBaseResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/knowledge-bases/{kb_id}": {
      "get": {
        "tags": [
          "Knowledge Bases",
          "Knowledge Bases"
        ],
        "summary": "Get Knowledge Base",
        "description": "Get a specific Knowledge Base by ID.",
        "operationId": "get_knowledge_base_knowledge_bases__kb_id__get",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "kb_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Kb Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KnowledgeBaseResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "Knowledge Bases",
          "Knowledge Bases"
        ],
        "summary": "Update Knowledge Base",
        "description": "Update a Knowledge Base (rename).",
        "operationId": "update_knowledge_base_knowledge_bases__kb_id__patch",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "kb_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Kb Id"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/KnowledgeBaseUpdate"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KnowledgeBaseResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Knowledge Bases",
          "Knowledge Bases"
        ],
        "summary": "Delete Knowledge Base",
        "description": "Delete a Knowledge Base and all its documents.\n\nThis also removes the KB from any agents that reference it.",
        "operationId": "delete_knowledge_base_knowledge_bases__kb_id__delete",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "kb_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Kb Id"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Successful Response"
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/knowledge-bases/{kb_id}/documents": {
      "get": {
        "tags": [
          "Knowledge Bases",
          "Knowledge Bases"
        ],
        "summary": "List Kb Documents",
        "description": "List all documents in a specific Knowledge Base.",
        "operationId": "list_kb_documents_knowledge_bases__kb_id__documents_get",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "kb_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Kb Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DocumentListResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Knowledge Bases",
          "Knowledge Bases"
        ],
        "summary": "Upload Kb Document",
        "description": "Upload a document to a specific Knowledge Base.\n\nSupports 100+ file types (validated by xAI). Max 48MB.",
        "operationId": "upload_kb_document_knowledge_bases__kb_id__documents_post",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "kb_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Kb Id"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "$ref": "#/components/schemas/Body_upload_kb_document_knowledge_bases__kb_id__documents_post"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DocumentResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/knowledge-bases/{kb_id}/stats": {
      "get": {
        "tags": [
          "Knowledge Bases",
          "Knowledge Bases"
        ],
        "summary": "Get Kb Stats",
        "description": "Get statistics for a specific Knowledge Base.",
        "operationId": "get_kb_stats_knowledge_bases__kb_id__stats_get",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "kb_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Kb Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CollectionStatsResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/knowledge-bases/{kb_id}/sources": {
      "get": {
        "tags": [
          "Knowledge Bases",
          "Knowledge Bases"
        ],
        "summary": "List Sources",
        "description": "List all sources for a Knowledge Base, optionally filtered by type.",
        "operationId": "list_sources_knowledge_bases__kb_id__sources_get",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "kb_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Kb Id"
            }
          },
          {
            "name": "source_type",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Source Type"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SourceListResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/knowledge-bases/{kb_id}/sources/{source_id}": {
      "delete": {
        "tags": [
          "Knowledge Bases",
          "Knowledge Bases"
        ],
        "summary": "Delete Source",
        "description": "Delete a KB source and its linked xAI document.",
        "operationId": "delete_source_knowledge_bases__kb_id__sources__source_id__delete",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "kb_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Kb Id"
            }
          },
          {
            "name": "source_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Source Id"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Successful Response"
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/knowledge-bases/{kb_id}/web-crawlers": {
      "get": {
        "tags": [
          "Knowledge Bases",
          "Knowledge Bases"
        ],
        "summary": "List Web Crawlers",
        "description": "List all web crawler sources for a KB.",
        "operationId": "list_web_crawlers_knowledge_bases__kb_id__web_crawlers_get",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "kb_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Kb Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/WebCrawlerResponse"
                  },
                  "title": "Response List Web Crawlers Knowledge Bases  Kb Id  Web Crawlers Get"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Knowledge Bases",
          "Knowledge Bases"
        ],
        "summary": "Create Web Crawler",
        "description": "Create a web crawler source and trigger initial crawl.",
        "operationId": "create_web_crawler_knowledge_bases__kb_id__web_crawlers_post",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "kb_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Kb Id"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebCrawlerCreate"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebCrawlerResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/knowledge-bases/{kb_id}/web-crawlers/{source_id}": {
      "get": {
        "tags": [
          "Knowledge Bases",
          "Knowledge Bases"
        ],
        "summary": "Get Web Crawler",
        "description": "Get a web crawler source.",
        "operationId": "get_web_crawler_knowledge_bases__kb_id__web_crawlers__source_id__get",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "kb_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Kb Id"
            }
          },
          {
            "name": "source_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Source Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebCrawlerResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/knowledge-bases/{kb_id}/web-crawlers/{source_id}/recrawl": {
      "post": {
        "tags": [
          "Knowledge Bases",
          "Knowledge Bases"
        ],
        "summary": "Trigger Recrawl",
        "description": "Trigger a re-crawl of the web source.",
        "operationId": "trigger_recrawl_knowledge_bases__kb_id__web_crawlers__source_id__recrawl_post",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "kb_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Kb Id"
            }
          },
          {
            "name": "source_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Source Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebCrawlerResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/knowledge-bases/{kb_id}/web-crawlers/{source_id}/schedule": {
      "patch": {
        "tags": [
          "Knowledge Bases",
          "Knowledge Bases"
        ],
        "summary": "Update Crawl Schedule",
        "description": "Update the recrawl schedule for a web crawler source.",
        "operationId": "update_crawl_schedule_knowledge_bases__kb_id__web_crawlers__source_id__schedule_patch",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "kb_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Kb Id"
            }
          },
          {
            "name": "source_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Source Id"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebCrawlerScheduleUpdate"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebCrawlerResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/knowledge-bases/{kb_id}/faqs": {
      "get": {
        "tags": [
          "Knowledge Bases",
          "Knowledge Bases"
        ],
        "summary": "List Faq Sources",
        "description": "List all FAQ sources for a KB with their pairs.",
        "operationId": "list_faq_sources_knowledge_bases__kb_id__faqs_get",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "kb_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Kb Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/FAQSourceResponse"
                  },
                  "title": "Response List Faq Sources Knowledge Bases  Kb Id  Faqs Get"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Knowledge Bases",
          "Knowledge Bases"
        ],
        "summary": "Create Faq Source",
        "description": "Create an FAQ source with optional initial pairs.",
        "operationId": "create_faq_source_knowledge_bases__kb_id__faqs_post",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "kb_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Kb Id"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/FAQSourceCreate"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FAQSourceResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/knowledge-bases/{kb_id}/faqs/{source_id}": {
      "get": {
        "tags": [
          "Knowledge Bases",
          "Knowledge Bases"
        ],
        "summary": "Get Faq Source",
        "description": "Get an FAQ source with all its pairs.",
        "operationId": "get_faq_source_knowledge_bases__kb_id__faqs__source_id__get",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "kb_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Kb Id"
            }
          },
          {
            "name": "source_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Source Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FAQSourceResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/knowledge-bases/{kb_id}/faqs/{source_id}/pairs": {
      "post": {
        "tags": [
          "Knowledge Bases",
          "Knowledge Bases"
        ],
        "summary": "Add Faq Pairs",
        "description": "Add FAQ pairs to an existing FAQ source.",
        "operationId": "add_faq_pairs_knowledge_bases__kb_id__faqs__source_id__pairs_post",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "kb_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Kb Id"
            }
          },
          {
            "name": "source_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Source Id"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/FAQPairCreate"
                },
                "title": "Pairs"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/FAQPairResponse"
                  },
                  "title": "Response Add Faq Pairs Knowledge Bases  Kb Id  Faqs  Source Id  Pairs Post"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/knowledge-bases/{kb_id}/faqs/{source_id}/pairs/{pair_id}": {
      "patch": {
        "tags": [
          "Knowledge Bases",
          "Knowledge Bases"
        ],
        "summary": "Update Faq Pair",
        "description": "Update a single FAQ pair.",
        "operationId": "update_faq_pair_knowledge_bases__kb_id__faqs__source_id__pairs__pair_id__patch",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "kb_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Kb Id"
            }
          },
          {
            "name": "source_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Source Id"
            }
          },
          {
            "name": "pair_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Pair Id"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/FAQPairUpdate"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FAQPairResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Knowledge Bases",
          "Knowledge Bases"
        ],
        "summary": "Delete Faq Pair",
        "description": "Delete a single FAQ pair.",
        "operationId": "delete_faq_pair_knowledge_bases__kb_id__faqs__source_id__pairs__pair_id__delete",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "kb_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Kb Id"
            }
          },
          {
            "name": "source_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Source Id"
            }
          },
          {
            "name": "pair_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Pair Id"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Successful Response"
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/knowledge-bases/{kb_id}/faqs/{source_id}/generate": {
      "post": {
        "tags": [
          "Knowledge Bases",
          "Knowledge Bases"
        ],
        "summary": "Generate Faqs",
        "description": "Use AI to generate FAQ pairs from provided content.",
        "operationId": "generate_faqs_knowledge_bases__kb_id__faqs__source_id__generate_post",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "kb_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Kb Id"
            }
          },
          {
            "name": "source_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Source Id"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/GenerateFAQRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/FAQPairResponse"
                  },
                  "title": "Response Generate Faqs Knowledge Bases  Kb Id  Faqs  Source Id  Generate Post"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/knowledge-bases/{kb_id}/rich-text": {
      "get": {
        "tags": [
          "Knowledge Bases",
          "Knowledge Bases"
        ],
        "summary": "List Rich Texts",
        "description": "List all rich text sources for a KB.",
        "operationId": "list_rich_texts_knowledge_bases__kb_id__rich_text_get",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "kb_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Kb Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/RichTextResponse"
                  },
                  "title": "Response List Rich Texts Knowledge Bases  Kb Id  Rich Text Get"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Knowledge Bases",
          "Knowledge Bases"
        ],
        "summary": "Create Rich Text",
        "description": "Create a rich text source and sync to xAI.",
        "operationId": "create_rich_text_knowledge_bases__kb_id__rich_text_post",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "kb_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Kb Id"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RichTextCreate"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RichTextResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/knowledge-bases/{kb_id}/rich-text/{source_id}": {
      "get": {
        "tags": [
          "Knowledge Bases",
          "Knowledge Bases"
        ],
        "summary": "Get Rich Text",
        "description": "Get a rich text source.",
        "operationId": "get_rich_text_knowledge_bases__kb_id__rich_text__source_id__get",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "kb_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Kb Id"
            }
          },
          {
            "name": "source_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Source Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RichTextResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "Knowledge Bases",
          "Knowledge Bases"
        ],
        "summary": "Update Rich Text",
        "description": "Update a rich text source and re-sync to xAI.",
        "operationId": "update_rich_text_knowledge_bases__kb_id__rich_text__source_id__patch",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "kb_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Kb Id"
            }
          },
          {
            "name": "source_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Source Id"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RichTextUpdate"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RichTextResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/knowledge-bases/{kb_id}/tables": {
      "get": {
        "tags": [
          "Knowledge Bases",
          "Knowledge Bases"
        ],
        "summary": "List Tables",
        "description": "List all table sources for a KB.",
        "operationId": "list_tables_knowledge_bases__kb_id__tables_get",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "kb_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Kb Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/TableSourceResponse"
                  },
                  "title": "Response List Tables Knowledge Bases  Kb Id  Tables Get"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Knowledge Bases",
          "Knowledge Bases"
        ],
        "summary": "Create Table Source",
        "description": "Create a table source and sync to xAI.",
        "operationId": "create_table_source_knowledge_bases__kb_id__tables_post",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "kb_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Kb Id"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TableSourceCreate"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TableSourceResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/knowledge-bases/{kb_id}/tables/{source_id}": {
      "get": {
        "tags": [
          "Knowledge Bases",
          "Knowledge Bases"
        ],
        "summary": "Get Table Source",
        "description": "Get a table source.",
        "operationId": "get_table_source_knowledge_bases__kb_id__tables__source_id__get",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "kb_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Kb Id"
            }
          },
          {
            "name": "source_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Source Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TableSourceResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "Knowledge Bases",
          "Knowledge Bases"
        ],
        "summary": "Update Table Source",
        "description": "Update a table source and re-sync to xAI.",
        "operationId": "update_table_source_knowledge_bases__kb_id__tables__source_id__patch",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "kb_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Kb Id"
            }
          },
          {
            "name": "source_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Source Id"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TableSourceUpdate"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TableSourceResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/knowledge-bases/{kb_id}/tables/parse-csv": {
      "post": {
        "tags": [
          "Knowledge Bases",
          "Knowledge Bases"
        ],
        "summary": "Parse Csv",
        "description": "Parse a CSV file and return headers + rows (does not create a source).",
        "operationId": "parse_csv_knowledge_bases__kb_id__tables_parse_csv_post",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "kb_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Kb Id"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "$ref": "#/components/schemas/Body_parse_csv_knowledge_bases__kb_id__tables_parse_csv_post"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/sequences/templates": {
      "get": {
        "tags": [
          "Sequences",
          "Sequences"
        ],
        "summary": "Get Templates",
        "description": "List available sequence templates.",
        "operationId": "get_templates_sequences_templates_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "items": {
                    "additionalProperties": true,
                    "type": "object"
                  },
                  "type": "array",
                  "title": "Response Get Templates Sequences Templates Get"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/sequences/voicemail/options": {
      "get": {
        "tags": [
          "Sequences",
          "Sequences"
        ],
        "summary": "Get Voicemail Options",
        "description": "Caller number pools, recordings and voices for voicemail steps.\n\nLists come from the connected voicemail provider. When they cannot load,\n``error`` says why in plain words and the lists are empty (never a 500).",
        "operationId": "get_voicemail_options_sequences_voicemail_options_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/VoicemailOptionsResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "APIKeyHeader": []
          }
        ]
      }
    },
    "/sequences": {
      "get": {
        "tags": [
          "Sequences",
          "Sequences"
        ],
        "summary": "List Sequences",
        "description": "List sequences for the current tenant.",
        "operationId": "list_sequences_sequences_get",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "maximum": 100,
              "minimum": 1,
              "default": 50,
              "title": "Limit"
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0,
              "title": "Offset"
            }
          },
          {
            "name": "is_active",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "boolean"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Is Active"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SequenceListResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Sequences",
          "Sequences"
        ],
        "summary": "Create Sequence",
        "description": "Create a new sequence.",
        "operationId": "create_sequence_sequences_post",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SequenceCreate"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SequenceResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/sequences/{sequence_id}": {
      "get": {
        "tags": [
          "Sequences",
          "Sequences"
        ],
        "summary": "Get Sequence",
        "description": "Get a sequence by ID.",
        "operationId": "get_sequence_sequences__sequence_id__get",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "sequence_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Sequence Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SequenceResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "Sequences",
          "Sequences"
        ],
        "summary": "Update Sequence",
        "description": "Update a sequence.",
        "operationId": "update_sequence_sequences__sequence_id__patch",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "sequence_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Sequence Id"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SequenceUpdate"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SequenceResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Sequences",
          "Sequences"
        ],
        "summary": "Delete Sequence",
        "description": "Delete a sequence. Must be inactive first.",
        "operationId": "delete_sequence_sequences__sequence_id__delete",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "sequence_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Sequence Id"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Successful Response"
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/sequences/{sequence_id}/activate": {
      "post": {
        "tags": [
          "Sequences",
          "Sequences"
        ],
        "summary": "Activate Sequence",
        "description": "Activate a sequence.",
        "operationId": "activate_sequence_sequences__sequence_id__activate_post",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "sequence_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Sequence Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SequenceResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/sequences/{sequence_id}/deactivate": {
      "post": {
        "tags": [
          "Sequences",
          "Sequences"
        ],
        "summary": "Deactivate Sequence",
        "description": "Deactivate a sequence.",
        "operationId": "deactivate_sequence_sequences__sequence_id__deactivate_post",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "sequence_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Sequence Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SequenceResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/sequences/{sequence_id}/enrollments": {
      "get": {
        "tags": [
          "Sequences",
          "Sequences"
        ],
        "summary": "List Enrollments",
        "description": "List enrollments for a sequence, newest first.\n\n``status`` keeps only enrollments in that status. ``search`` finds contacts by\nname, or by at least 3 digits of their phone number.",
        "operationId": "list_enrollments_sequences__sequence_id__enrollments_get",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "sequence_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Sequence Id"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "maximum": 100,
              "minimum": 1,
              "default": 50,
              "title": "Limit"
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0,
              "title": "Offset"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Status"
            }
          },
          {
            "name": "search",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "maxLength": 100
                },
                {
                  "type": "null"
                }
              ],
              "title": "Search"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EnrollmentListResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Sequences",
          "Sequences"
        ],
        "summary": "Enroll Contact",
        "description": "Enroll a single contact into a sequence.",
        "operationId": "enroll_contact_sequences__sequence_id__enrollments_post",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "sequence_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Sequence Id"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EnrollmentCreate"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EnrollmentResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/sequences/{sequence_id}/enrollments/csv": {
      "post": {
        "tags": [
          "Sequences",
          "Sequences"
        ],
        "summary": "Csv Import",
        "description": "Bulk enroll contacts from CSV data.",
        "operationId": "csv_import_sequences__sequence_id__enrollments_csv_post",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "sequence_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Sequence Id"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CSVImportRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CSVImportResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/sequences/{sequence_id}/enrollments/{enrollment_id}": {
      "delete": {
        "tags": [
          "Sequences",
          "Sequences"
        ],
        "summary": "Cancel Enrollment",
        "description": "Cancel an enrollment.",
        "operationId": "cancel_enrollment_sequences__sequence_id__enrollments__enrollment_id__delete",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "sequence_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Sequence Id"
            }
          },
          {
            "name": "enrollment_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Enrollment Id"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Successful Response"
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/sequences/{sequence_id}/enrollments/{enrollment_id}/dispositions": {
      "get": {
        "tags": [
          "Sequences",
          "Sequences"
        ],
        "summary": "Get Enrollment Dispositions",
        "description": "Get disposition log for an enrollment.\n\nThe enrollment must be this tenant's and belong to the sequence in the URL,\notherwise 404 (DAN-167 L-16). Both reads run off the event loop.",
        "operationId": "get_enrollment_dispositions_sequences__sequence_id__enrollments__enrollment_id__dispositions_get",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "sequence_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Sequence Id"
            }
          },
          {
            "name": "enrollment_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Enrollment Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {},
                  "title": "Response Get Enrollment Dispositions Sequences  Sequence Id  Enrollments  Enrollment Id  Dispositions Get"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/sequences/{sequence_id}/enrollments/{enrollment_id}/steps": {
      "get": {
        "tags": [
          "Sequences",
          "Sequences"
        ],
        "summary": "Get Enrollment Steps",
        "description": "What each step did for one contact, newest first, in plain words.\n\nA voicemail shows as waiting until Drop Cowboy reports back, then as\ndelivered or not delivered with the reason. A call shows what happened on\nit (answered, voicemail, no answer, ...) and a text whether it was\ndelivered (DAN-167 M-26). Every read runs off the event loop.",
        "operationId": "get_enrollment_steps_sequences__sequence_id__enrollments__enrollment_id__steps_get",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "sequence_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Sequence Id"
            }
          },
          {
            "name": "enrollment_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Enrollment Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnrollmentStepEntry"
                  },
                  "title": "Response Get Enrollment Steps Sequences  Sequence Id  Enrollments  Enrollment Id  Steps Get"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/sequences/{sequence_id}/stats": {
      "get": {
        "tags": [
          "Sequences",
          "Sequences"
        ],
        "summary": "Get Stats",
        "description": "Get enrollment stats for a sequence.",
        "operationId": "get_stats_sequences__sequence_id__stats_get",
        "security": [
          {
            "APIKeyHeader": []
          }
        ],
        "parameters": [
          {
            "name": "sequence_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Sequence Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SequenceStats"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/sequences/webhook/trigger": {
      "post": {
        "tags": [
          "Sequences",
          "Sequences"
        ],
        "summary": "Webhook Enrollment Trigger",
        "description": "GHL workflow triggers enrollment via this webhook.\n\nAccepts API key via Authorization header (preferred) or query param (legacy).\nThe Authorization header avoids key exposure in server/proxy access logs.",
        "operationId": "webhook_enrollment_trigger_sequences_webhook_trigger_post",
        "parameters": [
          {
            "name": "api_key",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "description": "Tenant API key (prefer Authorization header)",
              "title": "Api Key"
            },
            "description": "Tenant API key (prefer Authorization header)"
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true,
                  "title": "Response Webhook Enrollment Trigger Sequences Webhook Trigger Post"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "APIKeyCreate": {
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 255,
            "minLength": 1,
            "title": "Name",
            "default": "Default API Key"
          },
          "expires_in_days": {
            "anyOf": [
              {
                "type": "integer",
                "maximum": 365.0,
                "minimum": 1.0
              },
              {
                "type": "null"
              }
            ],
            "title": "Expires In Days"
          }
        },
        "type": "object",
        "title": "APIKeyCreate",
        "description": "Request to create a new API key."
      },
      "APIKeyCreateResponse": {
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "title": "Id"
          },
          "name": {
            "type": "string",
            "title": "Name"
          },
          "key_prefix": {
            "type": "string",
            "title": "Key Prefix"
          },
          "plaintext_key": {
            "type": "string",
            "title": "Plaintext Key"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "title": "Created At"
          },
          "expires_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Expires At"
          },
          "scope": {
            "anyOf": [
              {
                "type": "string",
                "enum": [
                  "agency",
                  "sub_account",
                  "direct"
                ]
              },
              {
                "type": "null"
              }
            ],
            "title": "Scope"
          }
        },
        "type": "object",
        "required": [
          "id",
          "name",
          "key_prefix",
          "plaintext_key",
          "created_at"
        ],
        "title": "APIKeyCreateResponse",
        "description": "Response after creating an API key (includes plaintext key ONCE)."
      },
      "APIKeyListResponse": {
        "properties": {
          "keys": {
            "items": {
              "$ref": "#/components/schemas/APIKeyResponse"
            },
            "type": "array",
            "title": "Keys"
          },
          "total": {
            "type": "integer",
            "title": "Total"
          },
          "scope": {
            "anyOf": [
              {
                "type": "string",
                "enum": [
                  "agency",
                  "sub_account",
                  "direct"
                ]
              },
              {
                "type": "null"
              }
            ],
            "title": "Scope"
          }
        },
        "type": "object",
        "required": [
          "keys",
          "total"
        ],
        "title": "APIKeyListResponse",
        "description": "List of API keys."
      },
      "APIKeyResponse": {
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "title": "Id"
          },
          "name": {
            "type": "string",
            "title": "Name"
          },
          "key_prefix": {
            "type": "string",
            "title": "Key Prefix"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "title": "Created At"
          },
          "last_used_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Last Used At"
          },
          "is_active": {
            "type": "boolean",
            "title": "Is Active",
            "default": true
          },
          "expires_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Expires At"
          }
        },
        "type": "object",
        "required": [
          "id",
          "name",
          "key_prefix",
          "created_at"
        ],
        "title": "APIKeyResponse",
        "description": "API key response (without the actual key)."
      },
      "AcceptInviteRequest": {
        "properties": {
          "token": {
            "type": "string",
            "maxLength": 100,
            "minLength": 20,
            "title": "Token"
          },
          "password": {
            "type": "string",
            "minLength": 6,
            "title": "Password",
            "description": "Minimum 6 characters (Supabase requirement)"
          }
        },
        "type": "object",
        "required": [
          "token",
          "password"
        ],
        "title": "AcceptInviteRequest",
        "description": "Request body for accepting a sub-account invite."
      },
      "AcceptOutboundTermsRequest": {
        "properties": {
          "terms_version": {
            "type": "string",
            "title": "Terms Version",
            "default": "1.0"
          }
        },
        "type": "object",
        "title": "AcceptOutboundTermsRequest",
        "description": "Request: accept outbound calling terms."
      },
      "AgencyIntegrationsResponse": {
        "properties": {
          "integrations": {
            "items": {
              "$ref": "#/components/schemas/IntegrationInfo"
            },
            "type": "array",
            "title": "Integrations"
          },
          "total_count": {
            "type": "integer",
            "title": "Total Count"
          }
        },
        "type": "object",
        "required": [
          "integrations",
          "total_count"
        ],
        "title": "AgencyIntegrationsResponse",
        "description": "List of agency's integrations available for assignment."
      },
      "AgencyOverview": {
        "properties": {
          "total_sub_accounts": {
            "type": "integer",
            "title": "Total Sub Accounts"
          },
          "active_sub_accounts": {
            "type": "integer",
            "title": "Active Sub Accounts"
          },
          "suspended_sub_accounts": {
            "type": "integer",
            "title": "Suspended Sub Accounts"
          },
          "total_agents": {
            "type": "integer",
            "title": "Total Agents"
          },
          "total_calls": {
            "type": "integer",
            "title": "Total Calls"
          },
          "total_minutes": {
            "type": "number",
            "title": "Total Minutes"
          },
          "total_texts": {
            "type": "integer",
            "title": "Total Texts",
            "default": 0
          },
          "total_margin_cents": {
            "type": "integer",
            "title": "Total Margin Cents"
          },
          "total_revenue_cents": {
            "type": "integer",
            "title": "Total Revenue Cents",
            "default": 0
          },
          "total_cost_cents": {
            "type": "integer",
            "title": "Total Cost Cents",
            "default": 0
          },
          "avg_margin_pct": {
            "type": "number",
            "title": "Avg Margin Pct",
            "default": 0.0
          },
          "total_booked": {
            "type": "integer",
            "title": "Total Booked",
            "default": 0
          },
          "conversion_rate": {
            "type": "number",
            "title": "Conversion Rate",
            "default": 0.0
          },
          "calls_by_direction": {
            "additionalProperties": {
              "type": "integer"
            },
            "type": "object",
            "title": "Calls By Direction",
            "default": {}
          },
          "top_sub_accounts": {
            "items": {
              "$ref": "#/components/schemas/SubAccountSummary"
            },
            "type": "array",
            "title": "Top Sub Accounts",
            "default": []
          },
          "usage_by_sub_account": {
            "items": {
              "$ref": "#/components/schemas/SubAccountSummary"
            },
            "type": "array",
            "title": "Usage By Sub Account",
            "default": []
          },
          "daily_trend": {
            "items": {
              "$ref": "#/components/schemas/DailyAgencyTrend"
            },
            "type": "array",
            "title": "Daily Trend",
            "default": []
          },
          "usage_by_provider": {
            "items": {
              "$ref": "#/components/schemas/ProviderBreakdown"
            },
            "type": "array",
            "title": "Usage By Provider",
            "default": []
          },
          "period_start": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Period Start"
          },
          "period_end": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Period End"
          },
          "period_source": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Period Source"
          }
        },
        "type": "object",
        "required": [
          "total_sub_accounts",
          "active_sub_accounts",
          "suspended_sub_accounts",
          "total_agents",
          "total_calls",
          "total_minutes",
          "total_margin_cents"
        ],
        "title": "AgencyOverview",
        "description": "Agency dashboard overview stats."
      },
      "AgentBreakdown": {
        "properties": {
          "agent_id": {
            "type": "string",
            "title": "Agent Id"
          },
          "agent_name": {
            "type": "string",
            "title": "Agent Name"
          },
          "calls": {
            "type": "integer",
            "title": "Calls",
            "default": 0
          },
          "minutes": {
            "type": "number",
            "title": "Minutes",
            "default": 0.0
          },
          "booked": {
            "type": "integer",
            "title": "Booked",
            "default": 0
          },
          "conversion_rate": {
            "type": "number",
            "title": "Conversion Rate",
            "default": 0.0
          }
        },
        "type": "object",
        "required": [
          "agent_id",
          "agent_name"
        ],
        "title": "AgentBreakdown",
        "description": "Per-agent aggregated stats."
      },
      "AgentCreate": {
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 255,
            "minLength": 2,
            "title": "Name"
          },
          "system_prompt": {
            "type": "string",
            "minLength": 10,
            "title": "System Prompt"
          },
          "greeting": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Greeting"
          },
          "greeting_outbound": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Greeting Outbound"
          },
          "voice": {
            "type": "string",
            "title": "Voice",
            "default": "ara"
          },
          "temperature": {
            "type": "number",
            "maximum": 2.0,
            "minimum": 0.0,
            "title": "Temperature",
            "default": 0.7
          },
          "business_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Business Name"
          },
          "industry": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Industry"
          },
          "ghl_phone_number": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Ghl Phone Number"
          },
          "calendar_provider": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Calendar Provider",
            "description": "Calendar provider: 'gohighlevel'"
          },
          "calendar_integration_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "title": "Calendar Integration Id",
            "description": "Which GHL integration to use (for multi-account support)"
          },
          "calendar_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Calendar Id",
            "description": "Calendar ID from provider"
          },
          "tools_enabled": {
            "anyOf": [
              {
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Tools Enabled",
            "description": "List of enabled tool names (e.g., ['end_call', 'book_appointment'])"
          },
          "timezone": {
            "type": "string",
            "title": "Timezone",
            "description": "IANA timezone (e.g., America/New_York, America/Los_Angeles)",
            "default": "America/New_York"
          },
          "vad_threshold": {
            "type": "number",
            "maximum": 1.0,
            "minimum": 0.0,
            "title": "Vad Threshold",
            "description": "VAD sensitivity (0.0-1.0, higher = less sensitive)",
            "default": 0.85
          },
          "vad_silence_duration_ms": {
            "type": "integer",
            "maximum": 2000.0,
            "minimum": 100.0,
            "title": "Vad Silence Duration Ms",
            "description": "Silence duration before ending turn (ms)",
            "default": 500
          },
          "vad_prefix_padding_ms": {
            "type": "integer",
            "maximum": 1000.0,
            "minimum": 0.0,
            "title": "Vad Prefix Padding Ms",
            "description": "Audio capture before speech detection (ms)",
            "default": 300
          },
          "xai_idle_timeout_ms": {
            "anyOf": [
              {
                "type": "integer",
                "maximum": 10000.0,
                "minimum": 0.0
              },
              {
                "type": "null"
              }
            ],
            "title": "Xai Idle Timeout Ms",
            "description": "xAI silence follow-up in ms (0-10000). Null = off. xAI provider only."
          },
          "xai_pronunciations": {
            "anyOf": [
              {
                "additionalProperties": {
                  "type": "string"
                },
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Xai Pronunciations",
            "description": "xAI pronunciation overrides: phrase -> spoken substitution. Null = off."
          },
          "enable_web_search": {
            "type": "boolean",
            "title": "Enable Web Search",
            "description": "Enable web search capability",
            "default": false
          },
          "enable_x_search": {
            "type": "boolean",
            "title": "Enable X Search",
            "description": "Enable X (Twitter) search",
            "default": false
          },
          "x_search_handles": {
            "anyOf": [
              {
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "X Search Handles",
            "description": "Allowed X handles for search (e.g., ['elonmusk', 'xai'])"
          },
          "enable_collections_search": {
            "type": "boolean",
            "title": "Enable Collections Search",
            "description": "Enable document search from tenant knowledge base",
            "default": false
          },
          "knowledge_base_ids": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Knowledge Base Ids",
            "description": "Knowledge Base IDs this agent can search (when enable_collections_search=true)"
          },
          "enable_recording_disclosure": {
            "type": "boolean",
            "title": "Enable Recording Disclosure",
            "description": "Announce call recording at start of calls (required for two-party consent states)",
            "default": true
          },
          "recording_enabled": {
            "type": "boolean",
            "title": "Recording Enabled",
            "description": "When true, defer GHL conversation sync and post-call webhook to recording.ready so the Twilio recording URL is included. When false, fire on call.completed without the recording URL.",
            "default": true
          },
          "enable_contact_intelligence": {
            "type": "boolean",
            "title": "Enable Contact Intelligence",
            "description": "Fetch caller context (GHL contact + call history) before answering",
            "default": false
          },
          "ai_speaks_first": {
            "type": "boolean",
            "title": "Ai Speaks First",
            "description": "If true, AI greets caller immediately. If false, AI waits for caller to speak first.",
            "default": true
          },
          "ai_speaks_first_outbound": {
            "type": "boolean",
            "title": "Ai Speaks First Outbound",
            "description": "If true, AI greets recipient immediately on outbound calls.",
            "default": true
          },
          "finish_greeting_before_listening": {
            "type": "boolean",
            "title": "Finish Greeting Before Listening",
            "description": "If true, caller cannot interrupt the agent's first response (inbound). Ignored if ai_speaks_first is false \u2014 validator will reject the combo.",
            "default": false
          },
          "finish_greeting_before_listening_outbound": {
            "type": "boolean",
            "title": "Finish Greeting Before Listening Outbound",
            "description": "If true, recipient cannot interrupt the agent's first response on outbound calls. Ignored if ai_speaks_first_outbound is false.",
            "default": false
          },
          "prompt_includes_contact_intelligence": {
            "type": "boolean",
            "title": "Prompt Includes Contact Intelligence",
            "description": "True if prompt includes Caller Intelligence section for using pre-call context",
            "default": false
          },
          "voice_provider": {
            "type": "string",
            "pattern": "^(xai|elevenlabs|openai|gemini|openai_live)$",
            "title": "Voice Provider",
            "description": "Voice provider: 'xai' (Grok), 'elevenlabs' (ElevenLabs), 'openai' (OpenAI), or 'gemini' (Gemini)",
            "default": "xai"
          },
          "openai_live_voice": {
            "type": "string",
            "title": "Openai Live Voice",
            "description": "GPT-Live voice name (12 options)",
            "default": "vesper"
          },
          "gemini_voice": {
            "type": "string",
            "title": "Gemini Voice",
            "description": "Gemini prebuilt voice name (30 options)",
            "default": "Puck"
          },
          "gemini_start_sensitivity": {
            "type": "string",
            "pattern": "^(low|high)$",
            "title": "Gemini Start Sensitivity",
            "description": "Gemini start-of-speech sensitivity: low (ignores noise) or high (reacts to everything)",
            "default": "low"
          },
          "gemini_end_sensitivity": {
            "type": "string",
            "pattern": "^(low|high)$",
            "title": "Gemini End Sensitivity",
            "description": "Gemini end-of-speech sensitivity: low (patient, waits for clear silence) or high (quick cutoff). WARNING: LOW on 8kHz telephony audio causes 15-30s latency spikes.",
            "default": "high"
          },
          "gemini_thinking_level": {
            "type": "string",
            "pattern": "^(none|minimal|low|medium|high)$",
            "title": "Gemini Thinking Level",
            "description": "Stored Gemini thinking level (none, minimal, low, medium, high). Accepted and returned for back-compat but NOT sent to the model: gemini-3.8-live does not support thinking levels, so this is currently a no-op.",
            "default": "none"
          },
          "gemini_language_code": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Gemini Language Code",
            "description": "BCP-47 language code hint for Gemini speech (e.g., 'en-US', 'es-US', 'fr-FR'). None = auto-detect."
          },
          "gemini_affective_dialog": {
            "type": "boolean",
            "title": "Gemini Affective Dialog",
            "description": "Deprecated no-op. Accepted and returned for back-compat; never sent. Affective dialog was removed from the Gemini Live API.",
            "default": false
          },
          "gemini_proactive_audio": {
            "type": "boolean",
            "title": "Gemini Proactive Audio",
            "description": "Deprecated no-op. Accepted and returned for back-compat; never sent. Proactive audio is permanently on for gemini-3.8-live and the field is rejected.",
            "default": false
          },
          "gemini_top_k": {
            "anyOf": [
              {
                "type": "integer",
                "maximum": 100.0,
                "minimum": 1.0
              },
              {
                "type": "null"
              }
            ],
            "title": "Gemini Top K",
            "description": "Gemini top-K sampling: number of top tokens considered (1-100, None=model default)"
          },
          "gemini_top_p": {
            "anyOf": [
              {
                "type": "number",
                "maximum": 1.0,
                "minimum": 0.0
              },
              {
                "type": "null"
              }
            ],
            "title": "Gemini Top P",
            "description": "Gemini top-P nucleus sampling threshold (0.0-1.0, None=model default)"
          },
          "openai_voice": {
            "type": "string",
            "title": "Openai Voice",
            "description": "OpenAI voice ID. v1.5 voices: alloy, ash, ballad, coral, echo, sage, shimmer, verse. v2 adds: marin, cedar (only available when openai_voice_model='gpt-realtime-2').",
            "default": "alloy"
          },
          "openai_vad_type": {
            "type": "string",
            "pattern": "^(semantic_vad|server_vad)$",
            "title": "Openai Vad Type",
            "description": "OpenAI VAD type: semantic_vad (AI-based) or server_vad (volume-based)",
            "default": "semantic_vad"
          },
          "openai_vad_eagerness": {
            "type": "string",
            "pattern": "^(low|medium|high|auto)$",
            "title": "Openai Vad Eagerness",
            "description": "OpenAI semantic VAD eagerness: low (patient) to high (responsive). Default medium (~4s max wait) \u2014 low waited up to ~8s and felt sluggish.",
            "default": "medium"
          },
          "openai_noise_reduction": {
            "type": "string",
            "pattern": "^(far_field|near_field|disabled)$",
            "title": "Openai Noise Reduction",
            "description": "OpenAI noise reduction: far_field (phone), near_field (mic), or disabled",
            "default": "far_field"
          },
          "openai_voice_model": {
            "type": "string",
            "pattern": "^(gpt-realtime-1\\.5|gpt-realtime-2|gpt-realtime-2\\.1|gpt-realtime-2\\.1-mini)$",
            "title": "Openai Voice Model",
            "description": "OpenAI Realtime model version. v1.5 is the default audio model; v2 adds reasoning at premium pricing.",
            "default": "gpt-realtime-1.5"
          },
          "openai_reasoning_effort": {
            "type": "string",
            "pattern": "^(minimal|low|medium|high|xhigh)$",
            "title": "Openai Reasoning Effort",
            "description": "Reasoning effort for gpt-realtime-2. Ignored on v1.5. Default 'low' is recommended for production voice.",
            "default": "low"
          },
          "elevenlabs_voice_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Elevenlabs Voice Id",
            "description": "ElevenLabs voice ID"
          },
          "elevenlabs_model_id": {
            "type": "string",
            "title": "Elevenlabs Model Id",
            "description": "LLM model ID for the ElevenLabs agent. Must be one of the curated models (see ALLOWED_ELEVENLABS_MODEL_IDS); claude-sonnet-5 is the ceiling. Anything above it bills a loss on Agency and Pro.",
            "default": "claude-sonnet-5"
          },
          "elevenlabs_speed": {
            "type": "number",
            "maximum": 1.2,
            "minimum": 0.7,
            "title": "Elevenlabs Speed",
            "description": "Speaking speed for ElevenLabs (0.7-1.2x)",
            "default": 1.0
          },
          "xai_speaking_speed": {
            "type": "number",
            "maximum": 1.5,
            "minimum": 0.7,
            "title": "Xai Speaking Speed",
            "description": "xAI playback speed multiplier (0.7-1.5x). Default 1.0. xAI provider only.",
            "default": 1.0
          },
          "xai_reasoning_effort": {
            "type": "string",
            "pattern": "^(high|none)$",
            "title": "Xai Reasoning Effort",
            "description": "xAI reasoning effort: 'high' or 'none'. Default 'none' (lower latency). xAI provider only.",
            "default": "none"
          },
          "xai_voice_model": {
            "type": "string",
            "pattern": "^(grok-voice-3\\.0|grok-voice-think-fast-1\\.0|grok-voice-think-fast-2\\.0)$",
            "title": "Xai Voice Model",
            "description": "xAI Speech-to-Speech model. Default 'grok-voice-3.0' (standard rate). 'grok-voice-think-fast-2.0' is the legacy premium tier and bills at a higher per-minute rate; 'grok-voice-think-fast-1.0' is legacy standard. xAI provider only.",
            "default": "grok-voice-3.0"
          },
          "elevenlabs_eagerness": {
            "type": "string",
            "pattern": "^(low|normal|high)$",
            "title": "Elevenlabs Eagerness",
            "description": "Turn-taking eagerness for ElevenLabs: 'low', 'normal', or 'high'",
            "default": "normal"
          },
          "elevenlabs_language": {
            "type": "string",
            "title": "Elevenlabs Language",
            "description": "Language code for ElevenLabs agent (e.g., 'en', 'es', 'fr')",
            "default": "en"
          },
          "elevenlabs_additional_languages": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Elevenlabs Additional Languages",
            "description": "Additional language codes for multilingual support (e.g., ['es', 'fr'])"
          },
          "elevenlabs_stability": {
            "type": "number",
            "maximum": 1.0,
            "minimum": 0.0,
            "title": "Elevenlabs Stability",
            "description": "Voice stability for ElevenLabs (0.0=creative, 0.5=natural, 1.0=robust)",
            "default": 0.5
          },
          "elevenlabs_max_duration_seconds": {
            "anyOf": [
              {
                "type": "integer",
                "minimum": 60.0
              },
              {
                "type": "null"
              }
            ],
            "title": "Elevenlabs Max Duration Seconds",
            "description": "Max call duration in seconds for ElevenLabs (None=unlimited, min 60)"
          },
          "elevenlabs_emotion_tags": {
            "anyOf": [
              {
                "items": {
                  "additionalProperties": {
                    "type": "string"
                  },
                  "type": "object"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Elevenlabs Emotion Tags",
            "description": "Custom emotion tags for ElevenLabs: [{name, description}]"
          },
          "elevenlabs_tool_call_sound": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Elevenlabs Tool Call Sound",
            "description": "Sound played during ElevenLabs tool execution: typing, elevator1-4, none",
            "default": "typing"
          },
          "elevenlabs_pre_tool_speech": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Elevenlabs Pre Tool Speech",
            "description": "Agent announces action before executing slow tools (ElevenLabs only)",
            "default": true
          },
          "xai_audio_tags": {
            "anyOf": [
              {
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Xai Audio Tags",
            "description": "xAI audio delivery tags: ['[breath]', '[pause]', '<whisper>', ...]"
          },
          "agent_mode": {
            "type": "string",
            "pattern": "^(inbound|outbound|both)$",
            "title": "Agent Mode",
            "description": "How this agent handles calls: 'inbound', 'outbound', or 'both'",
            "default": "inbound"
          },
          "voice_enabled": {
            "type": "boolean",
            "title": "Voice Enabled",
            "description": "Enable voice/phone channel",
            "default": true
          },
          "text_enabled": {
            "type": "boolean",
            "title": "Text Enabled",
            "description": "Enable text/SMS channel",
            "default": false
          },
          "amd_enabled": {
            "type": "boolean",
            "title": "Amd Enabled",
            "description": "Enable Twilio AMD for outbound calls ($0.01/call)",
            "default": true
          },
          "amd_voicemail_behavior": {
            "type": "string",
            "pattern": "^(hangup|static_message|dynamic_message|agent_decides)$",
            "title": "Amd Voicemail Behavior",
            "description": "Action when voicemail detected: hangup, static_message, dynamic_message, agent_decides",
            "default": "hangup"
          },
          "amd_voicemail_message": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 1000
              },
              {
                "type": "null"
              }
            ],
            "title": "Amd Voicemail Message",
            "description": "Message to leave on voicemail (supports {{variables}} for dynamic_message)"
          },
          "amd_voicemail_audio_url": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Amd Voicemail Audio Url",
            "description": "Audio file URL to play as voicemail (alternative to TTS)"
          },
          "inbound_webhook_enabled": {
            "type": "boolean",
            "title": "Inbound Webhook Enabled",
            "description": "Fire a pre-answer webhook on inbound calls to enrich/screen the call",
            "default": false
          },
          "inbound_webhook_url": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 2048
              },
              {
                "type": "null"
              }
            ],
            "title": "Inbound Webhook Url",
            "description": "HTTPS endpoint called before the agent answers"
          },
          "inbound_webhook_timeout_ms": {
            "type": "integer",
            "maximum": 10000.0,
            "minimum": 1000.0,
            "title": "Inbound Webhook Timeout Ms",
            "description": "Max wait for the webhook response (1000-10000ms, capped under Twilio's TwiML ceiling)",
            "default": 5000
          },
          "post_call_webhook_enabled": {
            "type": "boolean",
            "title": "Post Call Webhook Enabled",
            "description": "POST call results (summary, transcript, recording) to a URL after a call ends",
            "default": false
          },
          "post_call_webhook_url": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 2048
              },
              {
                "type": "null"
              }
            ],
            "title": "Post Call Webhook Url",
            "description": "HTTPS endpoint that receives the post-call payload"
          },
          "transfer_targets": {
            "anyOf": [
              {
                "items": {
                  "additionalProperties": true,
                  "type": "object"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Transfer Targets",
            "description": "Transfer targets: [{name, number, reason}]"
          },
          "transfer_to_agents": {
            "anyOf": [
              {
                "items": {
                  "additionalProperties": true,
                  "type": "object"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Transfer To Agents",
            "description": "Agent-to-agent transfer targets: [{agent_id, name, when}]. Each target must share this agent's tenant and voice_provider."
          },
          "whisper_enabled": {
            "type": "boolean",
            "title": "Whisper Enabled",
            "description": "Enable AI-generated whisper summary when transferring calls",
            "default": false
          },
          "ghl_tags": {
            "anyOf": [
              {
                "items": {
                  "additionalProperties": true,
                  "type": "object"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Ghl Tags",
            "description": "Available tags for GHL add_tag/remove_tag: [{name}]"
          },
          "ghl_remove_tags": {
            "anyOf": [
              {
                "items": {
                  "additionalProperties": true,
                  "type": "object"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Ghl Remove Tags",
            "description": "Tag rules for remove_tag: [{name, condition?}]"
          },
          "ghl_workflows": {
            "anyOf": [
              {
                "items": {
                  "additionalProperties": true,
                  "type": "object"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Ghl Workflows",
            "description": "Available workflows for GHL trigger_workflow: [{id, name, description?}]"
          },
          "ghl_pipelines": {
            "anyOf": [
              {
                "items": {
                  "additionalProperties": true,
                  "type": "object"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Ghl Pipelines",
            "description": "Available pipelines for GHL opportunities: [{id, name, stages: [{id, name}]}]"
          },
          "sms_templates": {
            "anyOf": [
              {
                "items": {
                  "additionalProperties": true,
                  "type": "object"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Sms Templates",
            "description": "SMS templates for send_sms: [{name, content}]"
          },
          "sms_phone_number_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "title": "Sms Phone Number Id",
            "description": "Phone number ID to use for send_sms tool (overrides agent's voice number)"
          },
          "max_call_duration_minutes": {
            "type": "integer",
            "maximum": 180.0,
            "minimum": 0.0,
            "title": "Max Call Duration Minutes",
            "description": "Max call duration in minutes (0=unlimited, max 180)",
            "default": 30
          },
          "max_silence_seconds": {
            "type": "integer",
            "maximum": 600.0,
            "minimum": 0.0,
            "title": "Max Silence Seconds",
            "description": "Max silence before ending call in seconds (0=unlimited, max 600)",
            "default": 120
          },
          "calendar_configs": {
            "anyOf": [
              {
                "items": {
                  "additionalProperties": true,
                  "type": "object"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Calendar Configs",
            "description": "Calendar configurations: [{calendar_id, integration_id, label, provider}]"
          },
          "multi_calendar_behavior": {
            "type": "string",
            "pattern": "^(ask_user|auto_first)$",
            "title": "Multi Calendar Behavior",
            "description": "Multi-calendar behavior: 'ask_user' (present options) or 'auto_first' (book first available)",
            "default": "ask_user"
          },
          "variable_definitions": {
            "anyOf": [
              {
                "items": {
                  "$ref": "#/components/schemas/VariableDefinition"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Variable Definitions",
            "description": "Template variables for prompt substitution: [{name, description?, required?, default_value?}]"
          },
          "tool_instructions": {
            "anyOf": [
              {
                "additionalProperties": {
                  "type": "string"
                },
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Tool Instructions",
            "description": "Per-tool usage instructions: {\"tool_name\": \"instruction text\"}"
          },
          "text_model": {
            "type": "string",
            "title": "Text Model",
            "description": "LLM for the text assistant. Must be one of ALLOWED_TEXT_MODEL_IDS. Runs on Leadlock-owned platform keys, so the set is enforced.",
            "default": "claude-haiku-4-5-20251001"
          },
          "channel_pivot_enabled": {
            "type": "boolean",
            "title": "Channel Pivot Enabled",
            "description": "Auto-send text when outbound call fails (no-answer, busy, voicemail)",
            "default": false
          },
          "mcp_servers": {
            "anyOf": [
              {
                "items": {
                  "$ref": "#/components/schemas/MCPServerConfig"
                },
                "type": "array",
                "maxItems": 5
              },
              {
                "type": "null"
              }
            ],
            "title": "Mcp Servers"
          }
        },
        "type": "object",
        "required": [
          "name",
          "system_prompt"
        ],
        "title": "AgentCreate",
        "description": "Request body for creating an agent."
      },
      "AgentFunctionResponse": {
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "title": "Id"
          },
          "function_id": {
            "type": "string",
            "format": "uuid",
            "title": "Function Id"
          },
          "agent_id": {
            "type": "string",
            "format": "uuid",
            "title": "Agent Id"
          },
          "is_enabled": {
            "type": "boolean",
            "title": "Is Enabled"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "title": "Created At"
          },
          "function": {
            "$ref": "#/components/schemas/CustomFunctionResponse"
          }
        },
        "type": "object",
        "required": [
          "id",
          "function_id",
          "agent_id",
          "is_enabled",
          "created_at",
          "function"
        ],
        "title": "AgentFunctionResponse",
        "description": "Response schema for a function attached to a specific agent."
      },
      "AgentFunctionsListResponse": {
        "properties": {
          "attached": {
            "items": {
              "$ref": "#/components/schemas/AgentFunctionResponse"
            },
            "type": "array",
            "title": "Attached",
            "description": "Functions attached to this agent"
          },
          "available": {
            "items": {
              "$ref": "#/components/schemas/CustomFunctionResponse"
            },
            "type": "array",
            "title": "Available",
            "description": "Library functions not yet attached to this agent"
          },
          "total_attached": {
            "type": "integer",
            "title": "Total Attached",
            "default": 0
          },
          "total_available": {
            "type": "integer",
            "title": "Total Available",
            "default": 0
          }
        },
        "type": "object",
        "title": "AgentFunctionsListResponse",
        "description": "Response for listing functions attached to an agent plus available library functions."
      },
      "AgentListResponse": {
        "properties": {
          "agents": {
            "items": {
              "$ref": "#/components/schemas/AgentResponse"
            },
            "type": "array",
            "title": "Agents"
          },
          "total": {
            "type": "integer",
            "title": "Total"
          }
        },
        "type": "object",
        "required": [
          "agents",
          "total"
        ],
        "title": "AgentListResponse",
        "description": "List of agents response."
      },
      "AgentResponse": {
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "title": "Id"
          },
          "tenant_id": {
            "type": "string",
            "format": "uuid",
            "title": "Tenant Id"
          },
          "name": {
            "type": "string",
            "title": "Name"
          },
          "is_active": {
            "type": "boolean",
            "title": "Is Active"
          },
          "voice": {
            "type": "string",
            "title": "Voice"
          },
          "temperature": {
            "type": "number",
            "title": "Temperature"
          },
          "business_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Business Name"
          },
          "industry": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Industry"
          },
          "system_prompt": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "System Prompt"
          },
          "greeting": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Greeting"
          },
          "greeting_outbound": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Greeting Outbound"
          },
          "ghl_phone_number": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Ghl Phone Number"
          },
          "calendar_provider": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Calendar Provider"
          },
          "calendar_integration_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "title": "Calendar Integration Id"
          },
          "calendar_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Calendar Id"
          },
          "tools_enabled": {
            "anyOf": [
              {
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Tools Enabled"
          },
          "timezone": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Timezone",
            "default": "America/New_York"
          },
          "vad_threshold": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "title": "Vad Threshold",
            "default": 0.65
          },
          "vad_silence_duration_ms": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Vad Silence Duration Ms",
            "default": 500
          },
          "vad_prefix_padding_ms": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Vad Prefix Padding Ms",
            "default": 300
          },
          "xai_idle_timeout_ms": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Xai Idle Timeout Ms"
          },
          "xai_pronunciations": {
            "anyOf": [
              {
                "additionalProperties": {
                  "type": "string"
                },
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Xai Pronunciations"
          },
          "enable_web_search": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Enable Web Search",
            "default": false
          },
          "enable_x_search": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Enable X Search",
            "default": false
          },
          "x_search_handles": {
            "anyOf": [
              {
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "X Search Handles"
          },
          "enable_collections_search": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Enable Collections Search",
            "default": false
          },
          "knowledge_base_ids": {
            "anyOf": [
              {
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Knowledge Base Ids"
          },
          "enable_recording_disclosure": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Enable Recording Disclosure",
            "default": true
          },
          "recording_enabled": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Recording Enabled",
            "default": true
          },
          "enable_contact_intelligence": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Enable Contact Intelligence",
            "default": false
          },
          "ai_speaks_first": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Ai Speaks First",
            "default": true
          },
          "ai_speaks_first_outbound": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Ai Speaks First Outbound",
            "default": true
          },
          "finish_greeting_before_listening": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Finish Greeting Before Listening",
            "default": false
          },
          "finish_greeting_before_listening_outbound": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Finish Greeting Before Listening Outbound",
            "default": false
          },
          "prompt_includes_contact_intelligence": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Prompt Includes Contact Intelligence",
            "default": false
          },
          "voice_provider": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Voice Provider",
            "default": "xai"
          },
          "openai_live_voice": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Openai Live Voice",
            "default": "vesper"
          },
          "gemini_voice": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Gemini Voice",
            "default": "Puck"
          },
          "gemini_start_sensitivity": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Gemini Start Sensitivity",
            "default": "low"
          },
          "gemini_end_sensitivity": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Gemini End Sensitivity",
            "default": "high"
          },
          "gemini_thinking_level": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Gemini Thinking Level",
            "default": "none"
          },
          "gemini_language_code": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Gemini Language Code"
          },
          "gemini_affective_dialog": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Gemini Affective Dialog",
            "default": false
          },
          "gemini_proactive_audio": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Gemini Proactive Audio",
            "default": false
          },
          "gemini_top_k": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Gemini Top K"
          },
          "gemini_top_p": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "title": "Gemini Top P"
          },
          "openai_voice": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Openai Voice",
            "default": "alloy"
          },
          "openai_vad_type": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Openai Vad Type",
            "default": "semantic_vad"
          },
          "openai_vad_eagerness": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Openai Vad Eagerness",
            "default": "medium"
          },
          "openai_noise_reduction": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Openai Noise Reduction",
            "default": "far_field"
          },
          "openai_voice_model": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Openai Voice Model",
            "default": "gpt-realtime-1.5"
          },
          "openai_reasoning_effort": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Openai Reasoning Effort",
            "default": "low"
          },
          "elevenlabs_voice_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Elevenlabs Voice Id"
          },
          "elevenlabs_model_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Elevenlabs Model Id",
            "default": "claude-sonnet-5"
          },
          "elevenlabs_speed": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "title": "Elevenlabs Speed",
            "default": 1.0
          },
          "xai_speaking_speed": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "title": "Xai Speaking Speed",
            "default": 1.0
          },
          "xai_reasoning_effort": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Xai Reasoning Effort",
            "default": "none"
          },
          "xai_voice_model": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Xai Voice Model",
            "default": "grok-voice-3.0"
          },
          "elevenlabs_eagerness": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Elevenlabs Eagerness",
            "default": "normal"
          },
          "elevenlabs_language": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Elevenlabs Language",
            "default": "en"
          },
          "elevenlabs_additional_languages": {
            "anyOf": [
              {
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Elevenlabs Additional Languages"
          },
          "elevenlabs_stability": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "title": "Elevenlabs Stability",
            "default": 0.5
          },
          "elevenlabs_max_duration_seconds": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Elevenlabs Max Duration Seconds"
          },
          "elevenlabs_emotion_tags": {
            "anyOf": [
              {
                "items": {
                  "additionalProperties": {
                    "type": "string"
                  },
                  "type": "object"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Elevenlabs Emotion Tags"
          },
          "elevenlabs_agent_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Elevenlabs Agent Id"
          },
          "elevenlabs_tool_call_sound": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Elevenlabs Tool Call Sound",
            "default": "typing"
          },
          "elevenlabs_pre_tool_speech": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Elevenlabs Pre Tool Speech",
            "default": true
          },
          "xai_audio_tags": {
            "anyOf": [
              {
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Xai Audio Tags"
          },
          "agent_mode": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Agent Mode",
            "default": "inbound"
          },
          "voice_enabled": {
            "type": "boolean",
            "title": "Voice Enabled",
            "default": true
          },
          "text_enabled": {
            "type": "boolean",
            "title": "Text Enabled",
            "default": false
          },
          "amd_enabled": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Amd Enabled",
            "default": true
          },
          "amd_voicemail_behavior": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Amd Voicemail Behavior",
            "default": "hangup"
          },
          "amd_voicemail_message": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Amd Voicemail Message"
          },
          "amd_voicemail_audio_url": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Amd Voicemail Audio Url"
          },
          "inbound_webhook_enabled": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Inbound Webhook Enabled",
            "default": false
          },
          "inbound_webhook_url": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Inbound Webhook Url"
          },
          "inbound_webhook_timeout_ms": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Inbound Webhook Timeout Ms",
            "default": 5000
          },
          "inbound_webhook_secret": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Inbound Webhook Secret"
          },
          "post_call_webhook_enabled": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Post Call Webhook Enabled",
            "default": false
          },
          "post_call_webhook_url": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Post Call Webhook Url"
          },
          "post_call_webhook_secret": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Post Call Webhook Secret"
          },
          "transfer_targets": {
            "anyOf": [
              {
                "items": {
                  "additionalProperties": true,
                  "type": "object"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Transfer Targets"
          },
          "transfer_to_agents": {
            "anyOf": [
              {
                "items": {
                  "additionalProperties": true,
                  "type": "object"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Transfer To Agents"
          },
          "whisper_enabled": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Whisper Enabled",
            "default": false
          },
          "ghl_tags": {
            "anyOf": [
              {
                "items": {
                  "additionalProperties": true,
                  "type": "object"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Ghl Tags"
          },
          "ghl_remove_tags": {
            "anyOf": [
              {
                "items": {
                  "additionalProperties": true,
                  "type": "object"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Ghl Remove Tags"
          },
          "ghl_workflows": {
            "anyOf": [
              {
                "items": {
                  "additionalProperties": true,
                  "type": "object"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Ghl Workflows"
          },
          "ghl_pipelines": {
            "anyOf": [
              {
                "items": {
                  "additionalProperties": true,
                  "type": "object"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Ghl Pipelines"
          },
          "sms_templates": {
            "anyOf": [
              {
                "items": {
                  "additionalProperties": true,
                  "type": "object"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Sms Templates"
          },
          "sms_phone_number_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "title": "Sms Phone Number Id"
          },
          "max_call_duration_minutes": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Max Call Duration Minutes",
            "default": 30
          },
          "max_silence_seconds": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Max Silence Seconds",
            "default": 120
          },
          "calendar_configs": {
            "anyOf": [
              {
                "items": {
                  "additionalProperties": true,
                  "type": "object"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Calendar Configs"
          },
          "multi_calendar_behavior": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Multi Calendar Behavior",
            "default": "ask_user"
          },
          "variable_definitions": {
            "anyOf": [
              {
                "items": {
                  "$ref": "#/components/schemas/VariableDefinition"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Variable Definitions"
          },
          "tool_instructions": {
            "anyOf": [
              {
                "additionalProperties": {
                  "type": "string"
                },
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Tool Instructions"
          },
          "text_model": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Text Model",
            "default": "claude-haiku-4-5-20251001"
          },
          "channel_pivot_enabled": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Channel Pivot Enabled",
            "default": false
          },
          "phone_count": {
            "type": "integer",
            "title": "Phone Count",
            "default": 0
          },
          "text_assistants": {
            "items": {
              "$ref": "#/components/schemas/LinkedTextAssistantSummary"
            },
            "type": "array",
            "title": "Text Assistants"
          },
          "mcp_servers": {
            "items": {
              "$ref": "#/components/schemas/MCPServerSummary"
            },
            "type": "array",
            "title": "Mcp Servers"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "title": "Created At"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "title": "Updated At"
          }
        },
        "type": "object",
        "required": [
          "id",
          "tenant_id",
          "name",
          "is_active",
          "voice",
          "temperature",
          "created_at",
          "updated_at"
        ],
        "title": "AgentResponse",
        "description": "Agent data response."
      },
      "AgentUpdate": {
        "properties": {
          "name": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 255,
                "minLength": 2
              },
              {
                "type": "null"
              }
            ],
            "title": "Name"
          },
          "system_prompt": {
            "anyOf": [
              {
                "type": "string",
                "minLength": 10
              },
              {
                "type": "null"
              }
            ],
            "title": "System Prompt"
          },
          "greeting": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Greeting"
          },
          "greeting_outbound": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Greeting Outbound"
          },
          "voice": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Voice"
          },
          "temperature": {
            "anyOf": [
              {
                "type": "number",
                "maximum": 2.0,
                "minimum": 0.0
              },
              {
                "type": "null"
              }
            ],
            "title": "Temperature"
          },
          "is_active": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Is Active"
          },
          "business_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Business Name"
          },
          "industry": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Industry"
          },
          "ghl_phone_number": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Ghl Phone Number"
          },
          "calendar_provider": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Calendar Provider"
          },
          "calendar_integration_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "title": "Calendar Integration Id"
          },
          "calendar_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Calendar Id"
          },
          "tools_enabled": {
            "anyOf": [
              {
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Tools Enabled"
          },
          "timezone": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Timezone"
          },
          "vad_threshold": {
            "anyOf": [
              {
                "type": "number",
                "maximum": 1.0,
                "minimum": 0.0
              },
              {
                "type": "null"
              }
            ],
            "title": "Vad Threshold"
          },
          "vad_silence_duration_ms": {
            "anyOf": [
              {
                "type": "integer",
                "maximum": 2000.0,
                "minimum": 100.0
              },
              {
                "type": "null"
              }
            ],
            "title": "Vad Silence Duration Ms"
          },
          "vad_prefix_padding_ms": {
            "anyOf": [
              {
                "type": "integer",
                "maximum": 1000.0,
                "minimum": 0.0
              },
              {
                "type": "null"
              }
            ],
            "title": "Vad Prefix Padding Ms"
          },
          "xai_idle_timeout_ms": {
            "anyOf": [
              {
                "type": "integer",
                "maximum": 10000.0,
                "minimum": 0.0
              },
              {
                "type": "null"
              }
            ],
            "title": "Xai Idle Timeout Ms"
          },
          "xai_pronunciations": {
            "anyOf": [
              {
                "additionalProperties": {
                  "type": "string"
                },
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Xai Pronunciations"
          },
          "enable_web_search": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Enable Web Search"
          },
          "enable_x_search": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Enable X Search"
          },
          "x_search_handles": {
            "anyOf": [
              {
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "X Search Handles"
          },
          "enable_collections_search": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Enable Collections Search"
          },
          "knowledge_base_ids": {
            "anyOf": [
              {
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Knowledge Base Ids"
          },
          "enable_recording_disclosure": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Enable Recording Disclosure"
          },
          "recording_enabled": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Recording Enabled"
          },
          "enable_contact_intelligence": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Enable Contact Intelligence"
          },
          "ai_speaks_first": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Ai Speaks First"
          },
          "ai_speaks_first_outbound": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Ai Speaks First Outbound"
          },
          "finish_greeting_before_listening": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Finish Greeting Before Listening"
          },
          "finish_greeting_before_listening_outbound": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Finish Greeting Before Listening Outbound"
          },
          "prompt_includes_contact_intelligence": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Prompt Includes Contact Intelligence"
          },
          "voice_provider": {
            "anyOf": [
              {
                "type": "string",
                "pattern": "^(xai|elevenlabs|openai|gemini|openai_live)$"
              },
              {
                "type": "null"
              }
            ],
            "title": "Voice Provider",
            "description": "Voice provider: 'xai' (Grok), 'elevenlabs' (ElevenLabs), 'openai' (OpenAI), or 'gemini' (Gemini)"
          },
          "openai_live_voice": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Openai Live Voice"
          },
          "gemini_voice": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Gemini Voice"
          },
          "gemini_start_sensitivity": {
            "anyOf": [
              {
                "type": "string",
                "pattern": "^(low|high)$"
              },
              {
                "type": "null"
              }
            ],
            "title": "Gemini Start Sensitivity"
          },
          "gemini_end_sensitivity": {
            "anyOf": [
              {
                "type": "string",
                "pattern": "^(low|high)$"
              },
              {
                "type": "null"
              }
            ],
            "title": "Gemini End Sensitivity"
          },
          "gemini_thinking_level": {
            "anyOf": [
              {
                "type": "string",
                "pattern": "^(none|minimal|low|medium|high)$"
              },
              {
                "type": "null"
              }
            ],
            "title": "Gemini Thinking Level"
          },
          "gemini_language_code": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Gemini Language Code"
          },
          "gemini_affective_dialog": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Gemini Affective Dialog"
          },
          "gemini_proactive_audio": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Gemini Proactive Audio"
          },
          "gemini_top_k": {
            "anyOf": [
              {
                "type": "integer",
                "maximum": 100.0,
                "minimum": 1.0
              },
              {
                "type": "null"
              }
            ],
            "title": "Gemini Top K"
          },
          "gemini_top_p": {
            "anyOf": [
              {
                "type": "number",
                "maximum": 1.0,
                "minimum": 0.0
              },
              {
                "type": "null"
              }
            ],
            "title": "Gemini Top P"
          },
          "openai_voice": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Openai Voice"
          },
          "openai_vad_type": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Openai Vad Type"
          },
          "openai_vad_eagerness": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Openai Vad Eagerness"
          },
          "openai_noise_reduction": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Openai Noise Reduction"
          },
          "openai_voice_model": {
            "anyOf": [
              {
                "type": "string",
                "pattern": "^(gpt-realtime-1\\.5|gpt-realtime-2|gpt-realtime-2\\.1|gpt-realtime-2\\.1-mini)$"
              },
              {
                "type": "null"
              }
            ],
            "title": "Openai Voice Model"
          },
          "openai_reasoning_effort": {
            "anyOf": [
              {
                "type": "string",
                "pattern": "^(minimal|low|medium|high|xhigh)$"
              },
              {
                "type": "null"
              }
            ],
            "title": "Openai Reasoning Effort"
          },
          "elevenlabs_voice_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Elevenlabs Voice Id"
          },
          "elevenlabs_model_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Elevenlabs Model Id"
          },
          "elevenlabs_speed": {
            "anyOf": [
              {
                "type": "number",
                "maximum": 1.2,
                "minimum": 0.7
              },
              {
                "type": "null"
              }
            ],
            "title": "Elevenlabs Speed"
          },
          "xai_speaking_speed": {
            "anyOf": [
              {
                "type": "number",
                "maximum": 1.5,
                "minimum": 0.7
              },
              {
                "type": "null"
              }
            ],
            "title": "Xai Speaking Speed"
          },
          "xai_reasoning_effort": {
            "anyOf": [
              {
                "type": "string",
                "pattern": "^(high|none)$"
              },
              {
                "type": "null"
              }
            ],
            "title": "Xai Reasoning Effort"
          },
          "xai_voice_model": {
            "anyOf": [
              {
                "type": "string",
                "pattern": "^(grok-voice-3\\.0|grok-voice-think-fast-1\\.0|grok-voice-think-fast-2\\.0)$"
              },
              {
                "type": "null"
              }
            ],
            "title": "Xai Voice Model"
          },
          "elevenlabs_eagerness": {
            "anyOf": [
              {
                "type": "string",
                "pattern": "^(low|normal|high)$"
              },
              {
                "type": "null"
              }
            ],
            "title": "Elevenlabs Eagerness"
          },
          "elevenlabs_language": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Elevenlabs Language"
          },
          "elevenlabs_additional_languages": {
            "anyOf": [
              {
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Elevenlabs Additional Languages"
          },
          "elevenlabs_stability": {
            "anyOf": [
              {
                "type": "number",
                "maximum": 1.0,
                "minimum": 0.0
              },
              {
                "type": "null"
              }
            ],
            "title": "Elevenlabs Stability"
          },
          "elevenlabs_max_duration_seconds": {
            "anyOf": [
              {
                "type": "integer",
                "minimum": 60.0
              },
              {
                "type": "null"
              }
            ],
            "title": "Elevenlabs Max Duration Seconds"
          },
          "elevenlabs_emotion_tags": {
            "anyOf": [
              {
                "items": {
                  "additionalProperties": {
                    "type": "string"
                  },
                  "type": "object"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Elevenlabs Emotion Tags"
          },
          "elevenlabs_tool_call_sound": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Elevenlabs Tool Call Sound"
          },
          "elevenlabs_pre_tool_speech": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Elevenlabs Pre Tool Speech"
          },
          "xai_audio_tags": {
            "anyOf": [
              {
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Xai Audio Tags"
          },
          "agent_mode": {
            "anyOf": [
              {
                "type": "string",
                "pattern": "^(inbound|outbound|both)$"
              },
              {
                "type": "null"
              }
            ],
            "title": "Agent Mode",
            "description": "How this agent handles calls"
          },
          "voice_enabled": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Voice Enabled"
          },
          "text_enabled": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Text Enabled"
          },
          "amd_enabled": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Amd Enabled"
          },
          "amd_voicemail_behavior": {
            "anyOf": [
              {
                "type": "string",
                "pattern": "^(hangup|static_message|dynamic_message|agent_decides)$"
              },
              {
                "type": "null"
              }
            ],
            "title": "Amd Voicemail Behavior"
          },
          "amd_voicemail_message": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 1000
              },
              {
                "type": "null"
              }
            ],
            "title": "Amd Voicemail Message"
          },
          "amd_voicemail_audio_url": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Amd Voicemail Audio Url"
          },
          "inbound_webhook_enabled": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Inbound Webhook Enabled"
          },
          "inbound_webhook_url": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 2048
              },
              {
                "type": "null"
              }
            ],
            "title": "Inbound Webhook Url"
          },
          "inbound_webhook_timeout_ms": {
            "anyOf": [
              {
                "type": "integer",
                "maximum": 10000.0,
                "minimum": 1000.0
              },
              {
                "type": "null"
              }
            ],
            "title": "Inbound Webhook Timeout Ms"
          },
          "post_call_webhook_enabled": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Post Call Webhook Enabled"
          },
          "post_call_webhook_url": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 2048
              },
              {
                "type": "null"
              }
            ],
            "title": "Post Call Webhook Url"
          },
          "transfer_targets": {
            "anyOf": [
              {
                "items": {
                  "additionalProperties": true,
                  "type": "object"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Transfer Targets"
          },
          "transfer_to_agents": {
            "anyOf": [
              {
                "items": {
                  "additionalProperties": true,
                  "type": "object"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Transfer To Agents"
          },
          "whisper_enabled": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Whisper Enabled"
          },
          "ghl_tags": {
            "anyOf": [
              {
                "items": {
                  "additionalProperties": true,
                  "type": "object"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Ghl Tags"
          },
          "ghl_remove_tags": {
            "anyOf": [
              {
                "items": {
                  "additionalProperties": true,
                  "type": "object"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Ghl Remove Tags"
          },
          "ghl_workflows": {
            "anyOf": [
              {
                "items": {
                  "additionalProperties": true,
                  "type": "object"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Ghl Workflows"
          },
          "ghl_pipelines": {
            "anyOf": [
              {
                "items": {
                  "additionalProperties": true,
                  "type": "object"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Ghl Pipelines"
          },
          "sms_templates": {
            "anyOf": [
              {
                "items": {
                  "additionalProperties": true,
                  "type": "object"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Sms Templates"
          },
          "sms_phone_number_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "title": "Sms Phone Number Id"
          },
          "max_call_duration_minutes": {
            "anyOf": [
              {
                "type": "integer",
                "maximum": 180.0,
                "minimum": 0.0
              },
              {
                "type": "null"
              }
            ],
            "title": "Max Call Duration Minutes"
          },
          "max_silence_seconds": {
            "anyOf": [
              {
                "type": "integer",
                "maximum": 600.0,
                "minimum": 0.0
              },
              {
                "type": "null"
              }
            ],
            "title": "Max Silence Seconds"
          },
          "calendar_configs": {
            "anyOf": [
              {
                "items": {
                  "additionalProperties": true,
                  "type": "object"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Calendar Configs"
          },
          "multi_calendar_behavior": {
            "anyOf": [
              {
                "type": "string",
                "pattern": "^(ask_user|auto_first)$"
              },
              {
                "type": "null"
              }
            ],
            "title": "Multi Calendar Behavior"
          },
          "variable_definitions": {
            "anyOf": [
              {
                "items": {
                  "$ref": "#/components/schemas/VariableDefinition"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Variable Definitions"
          },
          "tool_instructions": {
            "anyOf": [
              {
                "additionalProperties": {
                  "type": "string"
                },
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Tool Instructions"
          },
          "text_model": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Text Model"
          },
          "channel_pivot_enabled": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Channel Pivot Enabled"
          },
          "mcp_servers": {
            "anyOf": [
              {
                "items": {
                  "$ref": "#/components/schemas/MCPServerConfig"
                },
                "type": "array",
                "maxItems": 5
              },
              {
                "type": "null"
              }
            ],
            "title": "Mcp Servers"
          }
        },
        "type": "object",
        "title": "AgentUpdate",
        "description": "Request body for updating an agent."
      },
      "AllSubAccountAgentsResponse": {
        "properties": {
          "agents": {
            "items": {
              "$ref": "#/components/schemas/SubAccountAgentInfo"
            },
            "type": "array",
            "title": "Agents"
          },
          "total": {
            "type": "integer",
            "title": "Total"
          }
        },
        "type": "object",
        "required": [
          "agents",
          "total"
        ],
        "title": "AllSubAccountAgentsResponse",
        "description": "All agents across all sub-accounts (for agency overview)."
      },
      "AllSubAccountFunctionsResponse": {
        "properties": {
          "functions": {
            "items": {
              "$ref": "#/components/schemas/SubAccountFunctionInfo"
            },
            "type": "array",
            "title": "Functions"
          },
          "total": {
            "type": "integer",
            "title": "Total"
          }
        },
        "type": "object",
        "required": [
          "functions",
          "total"
        ],
        "title": "AllSubAccountFunctionsResponse",
        "description": "All custom functions across all sub-accounts (for agency sharing UI)."
      },
      "AnalysisCriterion": {
        "properties": {
          "name": {
            "type": "string",
            "title": "Name"
          },
          "description": {
            "type": "string",
            "title": "Description"
          }
        },
        "type": "object",
        "required": [
          "name",
          "description"
        ],
        "title": "AnalysisCriterion"
      },
      "AnalyticsResponse": {
        "properties": {
          "summary": {
            "$ref": "#/components/schemas/AnalyticsSummary"
          },
          "daily_trend": {
            "items": {
              "$ref": "#/components/schemas/DailyTrend"
            },
            "type": "array",
            "title": "Daily Trend"
          },
          "status_breakdown": {
            "items": {
              "$ref": "#/components/schemas/StatusBreakdown"
            },
            "type": "array",
            "title": "Status Breakdown"
          },
          "direction_breakdown": {
            "items": {
              "$ref": "#/components/schemas/DirectionBreakdown"
            },
            "type": "array",
            "title": "Direction Breakdown"
          },
          "agent_breakdown": {
            "items": {
              "$ref": "#/components/schemas/AgentBreakdown"
            },
            "type": "array",
            "title": "Agent Breakdown"
          }
        },
        "type": "object",
        "required": [
          "summary",
          "daily_trend",
          "status_breakdown",
          "direction_breakdown",
          "agent_breakdown"
        ],
        "title": "AnalyticsResponse",
        "description": "Single response for the analytics dashboard."
      },
      "AnalyticsSummary": {
        "properties": {
          "total_calls": {
            "type": "integer",
            "title": "Total Calls",
            "default": 0
          },
          "total_minutes": {
            "type": "number",
            "title": "Total Minutes",
            "default": 0.0
          },
          "total_cost_cents": {
            "type": "integer",
            "title": "Total Cost Cents",
            "default": 0
          },
          "conversion_rate": {
            "type": "number",
            "title": "Conversion Rate",
            "default": 0.0
          },
          "total_texts": {
            "type": "integer",
            "title": "Total Texts",
            "default": 0
          }
        },
        "type": "object",
        "title": "AnalyticsSummary",
        "description": "Totals for the selected period."
      },
      "AnalyzeCallsRequest": {
        "properties": {
          "call_ids": {
            "items": {
              "type": "string",
              "format": "uuid"
            },
            "type": "array",
            "maxItems": 50,
            "minItems": 1,
            "title": "Call Ids"
          },
          "criteria": {
            "items": {
              "$ref": "#/components/schemas/AnalysisCriterion"
            },
            "type": "array",
            "maxItems": 30,
            "title": "Criteria",
            "default": []
          },
          "model": {
            "type": "string",
            "title": "Model",
            "default": "openai/gpt-5.5"
          }
        },
        "type": "object",
        "required": [
          "call_ids"
        ],
        "title": "AnalyzeCallsRequest",
        "description": "Analyze one or more call transcripts. Empty criteria triggers diagnosis mode."
      },
      "ApplyCouponRequest": {
        "properties": {
          "promotion_code": {
            "type": "string",
            "title": "Promotion Code"
          }
        },
        "type": "object",
        "required": [
          "promotion_code"
        ],
        "title": "ApplyCouponRequest",
        "description": "Request to apply a promotion code to an existing subscription."
      },
      "ApplyCouponResponse": {
        "properties": {
          "success": {
            "type": "boolean",
            "title": "Success"
          },
          "discount_description": {
            "type": "string",
            "title": "Discount Description"
          }
        },
        "type": "object",
        "required": [
          "success",
          "discount_description"
        ],
        "title": "ApplyCouponResponse",
        "description": "Response after applying a coupon."
      },
      "ApplyPromptRequest": {
        "properties": {
          "original_text": {
            "type": "string",
            "title": "Original Text"
          },
          "suggested_text": {
            "type": "string",
            "title": "Suggested Text"
          }
        },
        "type": "object",
        "required": [
          "original_text",
          "suggested_text"
        ],
        "title": "ApplyPromptRequest",
        "description": "Apply a suggestion to the agent's system prompt."
      },
      "Appointment": {
        "properties": {
          "id": {
            "type": "string",
            "title": "Id"
          },
          "calendar_id": {
            "type": "string",
            "title": "Calendar Id"
          },
          "calendar_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Calendar Name"
          },
          "contact_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Contact Id"
          },
          "contact_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Contact Name"
          },
          "contact_phone": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Contact Phone"
          },
          "title": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Title"
          },
          "start_time": {
            "type": "string",
            "format": "date-time",
            "title": "Start Time"
          },
          "end_time": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "End Time"
          },
          "status": {
            "type": "string",
            "title": "Status"
          },
          "notes": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Notes"
          }
        },
        "type": "object",
        "required": [
          "id",
          "calendar_id",
          "start_time",
          "status"
        ],
        "title": "Appointment",
        "description": "Schema for a single GHL calendar appointment."
      },
      "AppointmentEntry": {
        "properties": {
          "datetime": {
            "type": "string",
            "title": "Datetime"
          },
          "appointment_id": {
            "type": "string",
            "title": "Appointment Id"
          }
        },
        "type": "object",
        "required": [
          "datetime",
          "appointment_id"
        ],
        "title": "AppointmentEntry",
        "description": "A single appointment entry from GHL."
      },
      "AppointmentsResponse": {
        "properties": {
          "appointments": {
            "items": {
              "$ref": "#/components/schemas/Appointment"
            },
            "type": "array",
            "title": "Appointments"
          },
          "total": {
            "type": "integer",
            "title": "Total"
          },
          "has_more": {
            "type": "boolean",
            "title": "Has More"
          },
          "integration_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Integration Id"
          }
        },
        "type": "object",
        "required": [
          "appointments",
          "total",
          "has_more"
        ],
        "title": "AppointmentsResponse",
        "description": "Response schema for appointments list endpoint."
      },
      "AssignIntegrationResponse": {
        "properties": {
          "success": {
            "type": "boolean",
            "title": "Success"
          },
          "sub_account_id": {
            "type": "string",
            "format": "uuid",
            "title": "Sub Account Id"
          },
          "integration_id": {
            "type": "string",
            "format": "uuid",
            "title": "Integration Id"
          },
          "provider": {
            "type": "string",
            "title": "Provider"
          },
          "account_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Account Name"
          }
        },
        "type": "object",
        "required": [
          "success",
          "sub_account_id",
          "integration_id",
          "provider"
        ],
        "title": "AssignIntegrationResponse",
        "description": "Response after assigning integration to sub-account."
      },
      "AssignIntegrationsRequest": {
        "properties": {
          "integration_ids": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "minItems": 1,
            "title": "Integration Ids"
          }
        },
        "type": "object",
        "required": [
          "integration_ids"
        ],
        "title": "AssignIntegrationsRequest",
        "description": "Request to assign multiple integrations to a sub-account."
      },
      "AssignIntegrationsResponse": {
        "properties": {
          "success": {
            "type": "boolean",
            "title": "Success"
          },
          "sub_account_id": {
            "type": "string",
            "format": "uuid",
            "title": "Sub Account Id"
          },
          "assigned": {
            "items": {
              "$ref": "#/components/schemas/AssignIntegrationResponse"
            },
            "type": "array",
            "title": "Assigned"
          },
          "errors": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Errors",
            "default": []
          }
        },
        "type": "object",
        "required": [
          "success",
          "sub_account_id",
          "assigned"
        ],
        "title": "AssignIntegrationsResponse",
        "description": "Response after assigning multiple integrations to sub-account."
      },
      "AssignPhoneNumberRequest": {
        "properties": {
          "sub_account_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "title": "Sub Account Id",
            "description": "Sub-account ID to assign to, or None to unassign"
          }
        },
        "type": "object",
        "title": "AssignPhoneNumberRequest",
        "description": "Request to assign a phone number to a sub-account."
      },
      "AttachFunctionRequest": {
        "properties": {
          "function_id": {
            "type": "string",
            "format": "uuid",
            "title": "Function Id",
            "description": "ID of the function to attach"
          },
          "is_enabled": {
            "type": "boolean",
            "title": "Is Enabled",
            "description": "Whether function is enabled for this agent",
            "default": true
          }
        },
        "type": "object",
        "required": [
          "function_id"
        ],
        "title": "AttachFunctionRequest",
        "description": "Request to attach a library function to an agent."
      },
      "AttachFunctionResponse": {
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "title": "Id"
          },
          "agent_id": {
            "type": "string",
            "format": "uuid",
            "title": "Agent Id"
          },
          "function_id": {
            "type": "string",
            "format": "uuid",
            "title": "Function Id"
          },
          "is_enabled": {
            "type": "boolean",
            "title": "Is Enabled"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "title": "Created At"
          }
        },
        "type": "object",
        "required": [
          "id",
          "agent_id",
          "function_id",
          "is_enabled",
          "created_at"
        ],
        "title": "AttachFunctionResponse",
        "description": "Response after attaching a function to an agent."
      },
      "AuthResponse": {
        "properties": {
          "access_token": {
            "type": "string",
            "title": "Access Token"
          },
          "refresh_token": {
            "type": "string",
            "title": "Refresh Token"
          },
          "token_type": {
            "type": "string",
            "title": "Token Type",
            "default": "bearer"
          },
          "expires_in": {
            "type": "integer",
            "title": "Expires In"
          },
          "user": {
            "$ref": "#/components/schemas/UserResponse"
          },
          "tenant": {
            "$ref": "#/components/schemas/TenantResponse"
          }
        },
        "type": "object",
        "required": [
          "access_token",
          "refresh_token",
          "expires_in",
          "user",
          "tenant"
        ],
        "title": "AuthResponse",
        "description": "Full authentication response with tokens, user, and tenant."
      },
      "BYOKKeyCreate": {
        "properties": {
          "provider": {
            "type": "string",
            "pattern": "^(openai|anthropic|xai|drop_cowboy|slybroadcast)$",
            "title": "Provider"
          },
          "api_key": {
            "type": "string",
            "minLength": 10,
            "title": "Api Key"
          },
          "label": {
            "type": "string",
            "title": "Label",
            "default": ""
          }
        },
        "type": "object",
        "required": [
          "provider",
          "api_key"
        ],
        "title": "BYOKKeyCreate"
      },
      "Body_create_issue_issues__post": {
        "properties": {
          "message": {
            "type": "string",
            "maxLength": 2000,
            "minLength": 10,
            "title": "Message"
          },
          "url": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Url"
          },
          "page_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Page Name"
          },
          "browser_info": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Browser Info"
          },
          "image": {
            "anyOf": [
              {
                "type": "string",
                "contentMediaType": "application/octet-stream"
              },
              {
                "type": "null"
              }
            ],
            "title": "Image"
          }
        },
        "type": "object",
        "required": [
          "message"
        ],
        "title": "Body_create_issue_issues__post"
      },
      "Body_handle_amd_status_webhooks_twilio__tenant_id__amd_status_post": {
        "properties": {
          "CallSid": {
            "type": "string",
            "title": "Callsid"
          },
          "AnsweredBy": {
            "type": "string",
            "title": "Answeredby"
          },
          "MachineDetectionDuration": {
            "type": "string",
            "title": "Machinedetectionduration",
            "default": "0"
          }
        },
        "type": "object",
        "required": [
          "CallSid",
          "AnsweredBy"
        ],
        "title": "Body_handle_amd_status_webhooks_twilio__tenant_id__amd_status_post"
      },
      "Body_handle_call_status_webhooks_twilio__tenant_id__status_post": {
        "properties": {
          "CallSid": {
            "type": "string",
            "title": "Callsid"
          },
          "CallStatus": {
            "type": "string",
            "title": "Callstatus"
          },
          "CallDuration": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Callduration"
          },
          "Timestamp": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Timestamp"
          }
        },
        "type": "object",
        "required": [
          "CallSid",
          "CallStatus"
        ],
        "title": "Body_handle_call_status_webhooks_twilio__tenant_id__status_post"
      },
      "Body_handle_incoming_sms_webhooks_twilio__tenant_id__sms_post": {
        "properties": {
          "From": {
            "type": "string",
            "title": "From"
          },
          "To": {
            "type": "string",
            "title": "To"
          },
          "Body": {
            "type": "string",
            "title": "Body",
            "default": ""
          },
          "MessageSid": {
            "type": "string",
            "title": "Messagesid"
          },
          "AccountSid": {
            "type": "string",
            "title": "Accountsid",
            "default": ""
          },
          "NumMedia": {
            "type": "string",
            "title": "Nummedia",
            "default": "0"
          }
        },
        "type": "object",
        "required": [
          "From",
          "To",
          "MessageSid"
        ],
        "title": "Body_handle_incoming_sms_webhooks_twilio__tenant_id__sms_post"
      },
      "Body_handle_incoming_voice_webhooks_twilio__tenant_id__voice_post": {
        "properties": {
          "CallSid": {
            "type": "string",
            "title": "Callsid"
          },
          "From": {
            "type": "string",
            "title": "From"
          },
          "To": {
            "type": "string",
            "title": "To"
          },
          "CallStatus": {
            "type": "string",
            "title": "Callstatus",
            "default": "ringing"
          },
          "Direction": {
            "type": "string",
            "title": "Direction",
            "default": "inbound"
          }
        },
        "type": "object",
        "required": [
          "CallSid",
          "From",
          "To"
        ],
        "title": "Body_handle_incoming_voice_webhooks_twilio__tenant_id__voice_post"
      },
      "Body_handle_recording_ready_webhooks_twilio__tenant_id__recording_post": {
        "properties": {
          "CallSid": {
            "type": "string",
            "title": "Callsid"
          },
          "RecordingUrl": {
            "type": "string",
            "title": "Recordingurl"
          },
          "RecordingDuration": {
            "type": "string",
            "title": "Recordingduration",
            "default": "0"
          },
          "RecordingSid": {
            "type": "string",
            "title": "Recordingsid"
          }
        },
        "type": "object",
        "required": [
          "CallSid",
          "RecordingUrl",
          "RecordingSid"
        ],
        "title": "Body_handle_recording_ready_webhooks_twilio__tenant_id__recording_post"
      },
      "Body_handle_sms_status_callback_webhooks_twilio__tenant_id__sms_status_post": {
        "properties": {
          "MessageSid": {
            "type": "string",
            "title": "Messagesid"
          },
          "MessageStatus": {
            "type": "string",
            "title": "Messagestatus"
          },
          "From": {
            "type": "string",
            "title": "From",
            "default": ""
          },
          "To": {
            "type": "string",
            "title": "To",
            "default": ""
          },
          "ErrorCode": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Errorcode"
          },
          "AccountSid": {
            "type": "string",
            "title": "Accountsid",
            "default": ""
          }
        },
        "type": "object",
        "required": [
          "MessageSid",
          "MessageStatus"
        ],
        "title": "Body_handle_sms_status_callback_webhooks_twilio__tenant_id__sms_status_post"
      },
      "Body_parse_csv_knowledge_bases__kb_id__tables_parse_csv_post": {
        "properties": {
          "file": {
            "type": "string",
            "contentMediaType": "application/octet-stream",
            "title": "File"
          }
        },
        "type": "object",
        "required": [
          "file"
        ],
        "title": "Body_parse_csv_knowledge_bases__kb_id__tables_parse_csv_post"
      },
      "Body_upload_demo_image_demos__demo_id__upload_image_post": {
        "properties": {
          "file": {
            "type": "string",
            "contentMediaType": "application/octet-stream",
            "title": "File"
          }
        },
        "type": "object",
        "required": [
          "file"
        ],
        "title": "Body_upload_demo_image_demos__demo_id__upload_image_post"
      },
      "Body_upload_document_documents_post": {
        "properties": {
          "file": {
            "type": "string",
            "contentMediaType": "application/octet-stream",
            "title": "File"
          },
          "description": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Description"
          }
        },
        "type": "object",
        "required": [
          "file"
        ],
        "title": "Body_upload_document_documents_post"
      },
      "Body_upload_favicon_agency_branding_favicon_post": {
        "properties": {
          "file": {
            "type": "string",
            "contentMediaType": "application/octet-stream",
            "title": "File"
          }
        },
        "type": "object",
        "required": [
          "file"
        ],
        "title": "Body_upload_favicon_agency_branding_favicon_post"
      },
      "Body_upload_kb_document_knowledge_bases__kb_id__documents_post": {
        "properties": {
          "file": {
            "type": "string",
            "contentMediaType": "application/octet-stream",
            "title": "File"
          },
          "description": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Description"
          }
        },
        "type": "object",
        "required": [
          "file"
        ],
        "title": "Body_upload_kb_document_knowledge_bases__kb_id__documents_post"
      },
      "Body_upload_logo_agency_branding_logo_post": {
        "properties": {
          "file": {
            "type": "string",
            "contentMediaType": "application/octet-stream",
            "title": "File"
          }
        },
        "type": "object",
        "required": [
          "file"
        ],
        "title": "Body_upload_logo_agency_branding_logo_post"
      },
      "BrandingSettings": {
        "properties": {
          "company_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Company Name"
          },
          "logo_url": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Logo Url"
          },
          "favicon_url": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Favicon Url"
          },
          "primary_color": {
            "type": "string",
            "title": "Primary Color",
            "default": "#6298B6"
          },
          "support_email": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Support Email"
          },
          "support_url": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Support Url"
          }
        },
        "type": "object",
        "title": "BrandingSettings",
        "description": "Agency branding settings."
      },
      "BusinessHoursDay": {
        "properties": {
          "start": {
            "type": "string",
            "title": "Start",
            "default": "09:00"
          },
          "end": {
            "type": "string",
            "title": "End",
            "default": "17:00"
          },
          "enabled": {
            "type": "boolean",
            "title": "Enabled",
            "default": true
          }
        },
        "type": "object",
        "title": "BusinessHoursDay",
        "description": "Business hours configuration for a single day."
      },
      "CSVImportRequest": {
        "properties": {
          "rows": {
            "items": {
              "additionalProperties": {
                "type": "string"
              },
              "type": "object"
            },
            "type": "array",
            "title": "Rows",
            "description": "Parsed CSV rows with mapped field names"
          },
          "field_mapping": {
            "additionalProperties": {
              "type": "string"
            },
            "type": "object",
            "title": "Field Mapping",
            "description": "CSV column \u2192 schema field mapping"
          },
          "allow_inactive": {
            "type": "boolean",
            "title": "Allow Inactive",
            "default": false
          },
          "launch": {
            "type": "boolean",
            "title": "Launch",
            "default": false
          }
        },
        "type": "object",
        "required": [
          "rows",
          "field_mapping"
        ],
        "title": "CSVImportRequest",
        "description": "Bulk enrollment from CSV data."
      },
      "CSVImportResponse": {
        "properties": {
          "enrolled": {
            "type": "integer",
            "title": "Enrolled"
          },
          "skipped": {
            "type": "integer",
            "title": "Skipped"
          },
          "errors": {
            "items": {
              "additionalProperties": true,
              "type": "object"
            },
            "type": "array",
            "title": "Errors"
          }
        },
        "type": "object",
        "required": [
          "enrolled",
          "skipped",
          "errors"
        ],
        "title": "CSVImportResponse"
      },
      "CalendarInfo": {
        "properties": {
          "id": {
            "type": "string",
            "title": "Id"
          },
          "name": {
            "type": "string",
            "title": "Name"
          },
          "provider": {
            "type": "string",
            "title": "Provider"
          },
          "location_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Location Id"
          },
          "duration_minutes": {
            "type": "integer",
            "title": "Duration Minutes",
            "default": 30
          }
        },
        "type": "object",
        "required": [
          "id",
          "name",
          "provider"
        ],
        "title": "CalendarInfo",
        "description": "Information about a calendar/event type."
      },
      "CallHistorySummary": {
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "title": "Id"
          },
          "direction": {
            "type": "string",
            "title": "Direction"
          },
          "status": {
            "type": "string",
            "title": "Status"
          },
          "duration_seconds": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Duration Seconds"
          },
          "started_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Started At"
          },
          "agent_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Agent Name"
          },
          "has_transcript": {
            "type": "boolean",
            "title": "Has Transcript",
            "default": false
          },
          "summary": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Summary"
          },
          "sentiment": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Sentiment"
          },
          "caller_reason": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Caller Reason"
          },
          "appointment_booked": {
            "type": "boolean",
            "title": "Appointment Booked",
            "default": false
          }
        },
        "type": "object",
        "required": [
          "id",
          "direction",
          "status"
        ],
        "title": "CallHistorySummary",
        "description": "Summary of a call for contact detail view."
      },
      "CallLogListItem": {
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "title": "Id"
          },
          "tenant_id": {
            "type": "string",
            "format": "uuid",
            "title": "Tenant Id"
          },
          "agent_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "title": "Agent Id"
          },
          "agent_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Agent Name"
          },
          "twilio_call_sid": {
            "type": "string",
            "title": "Twilio Call Sid"
          },
          "direction": {
            "type": "string",
            "enum": [
              "inbound",
              "outbound",
              "test",
              "demo",
              "web"
            ],
            "title": "Direction"
          },
          "from_number": {
            "type": "string",
            "title": "From Number"
          },
          "to_number": {
            "type": "string",
            "title": "To Number"
          },
          "status": {
            "type": "string",
            "title": "Status"
          },
          "started_at": {
            "type": "string",
            "format": "date-time",
            "title": "Started At"
          },
          "ended_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Ended At"
          },
          "duration_seconds": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Duration Seconds"
          },
          "billable_minutes": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Billable Minutes"
          },
          "cost_cents": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Cost Cents"
          },
          "caller_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Caller Name"
          },
          "caller_email": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Caller Email"
          },
          "metadata": {
            "anyOf": [
              {
                "additionalProperties": true,
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Metadata"
          },
          "appointment_booked": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Appointment Booked"
          },
          "amd_status": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Amd Status"
          }
        },
        "type": "object",
        "required": [
          "id",
          "tenant_id",
          "twilio_call_sid",
          "direction",
          "from_number",
          "to_number",
          "status",
          "started_at"
        ],
        "title": "CallLogListItem",
        "description": "Fields returned by GET /calls (list).\n\nMirrors CALL_LIST_PROJECTION in service.py exactly. Columns the narrow\nprojection does not fetch are declared on CallLogResponse instead, so a\nlist row never advertises a field it cannot populate. Declaring them here\nwould serialise them as `null` on every row, which a client cannot\ndistinguish from \"this call genuinely has no transcript\" -- that ambiguity\ncaused a customer to report a 100% call failure against a healthy pipeline.\nSee the SNAP-3 comment on CALL_LIST_PROJECTION for why the list stays narrow."
      },
      "CallLogListResponse": {
        "properties": {
          "calls": {
            "items": {
              "$ref": "#/components/schemas/CallLogListItem"
            },
            "type": "array",
            "title": "Calls"
          },
          "total": {
            "type": "integer",
            "title": "Total"
          }
        },
        "type": "object",
        "required": [
          "calls",
          "total"
        ],
        "title": "CallLogListResponse",
        "description": "Response schema for listing call logs."
      },
      "CallLogResponse": {
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "title": "Id"
          },
          "tenant_id": {
            "type": "string",
            "format": "uuid",
            "title": "Tenant Id"
          },
          "agent_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "title": "Agent Id"
          },
          "agent_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Agent Name"
          },
          "twilio_call_sid": {
            "type": "string",
            "title": "Twilio Call Sid"
          },
          "direction": {
            "type": "string",
            "enum": [
              "inbound",
              "outbound",
              "test",
              "demo",
              "web"
            ],
            "title": "Direction"
          },
          "from_number": {
            "type": "string",
            "title": "From Number"
          },
          "to_number": {
            "type": "string",
            "title": "To Number"
          },
          "status": {
            "type": "string",
            "title": "Status"
          },
          "started_at": {
            "type": "string",
            "format": "date-time",
            "title": "Started At"
          },
          "ended_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Ended At"
          },
          "duration_seconds": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Duration Seconds"
          },
          "billable_minutes": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Billable Minutes"
          },
          "cost_cents": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Cost Cents"
          },
          "caller_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Caller Name"
          },
          "caller_email": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Caller Email"
          },
          "metadata": {
            "anyOf": [
              {
                "additionalProperties": true,
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Metadata"
          },
          "appointment_booked": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Appointment Booked"
          },
          "amd_status": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Amd Status"
          },
          "phone_number_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "title": "Phone Number Id"
          },
          "recording_url": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Recording Url"
          },
          "recording_duration_seconds": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Recording Duration Seconds"
          },
          "transcript": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "items": {
                  "additionalProperties": true,
                  "type": "object"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Transcript"
          },
          "amd_detection_ms": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Amd Detection Ms"
          },
          "voice_provider": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Voice Provider"
          }
        },
        "type": "object",
        "required": [
          "id",
          "tenant_id",
          "twilio_call_sid",
          "direction",
          "from_number",
          "to_number",
          "status",
          "started_at"
        ],
        "title": "CallLogResponse",
        "description": "Response schema for a single call log entry (GET /calls/{id}).\n\nAdds the columns CALL_LIST_PROJECTION deliberately omits from the list."
      },
      "ChangePlanRequest": {
        "properties": {
          "plan": {
            "type": "string",
            "enum": [
              "starter",
              "agency",
              "pro"
            ],
            "title": "Plan"
          }
        },
        "type": "object",
        "required": [
          "plan"
        ],
        "title": "ChangePlanRequest",
        "description": "Request to move an existing subscription to a different plan."
      },
      "ChangePlanResponse": {
        "properties": {
          "success": {
            "type": "boolean",
            "title": "Success"
          },
          "plan": {
            "type": "string",
            "title": "Plan"
          },
          "subscription_status": {
            "type": "string",
            "title": "Subscription Status"
          },
          "trial_ended": {
            "type": "boolean",
            "title": "Trial Ended"
          },
          "message": {
            "type": "string",
            "title": "Message"
          }
        },
        "type": "object",
        "required": [
          "success",
          "plan",
          "subscription_status",
          "trial_ended",
          "message"
        ],
        "title": "ChangePlanResponse",
        "description": "Result of a plan change."
      },
      "ChannelConfig": {
        "properties": {
          "enabled": {
            "type": "boolean",
            "title": "Enabled",
            "default": true
          },
          "accounts": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Accounts"
          }
        },
        "type": "object",
        "title": "ChannelConfig",
        "description": "Per-channel configuration with optional account filtering.\n\nWhen accounts is empty, responds to ALL accounts for that channel.\nWhen accounts has values, only responds to those specific accounts."
      },
      "ChatAssistantBreakdown": {
        "properties": {
          "assistant_id": {
            "type": "string",
            "title": "Assistant Id"
          },
          "assistant_name": {
            "type": "string",
            "title": "Assistant Name"
          },
          "conversations": {
            "type": "integer",
            "title": "Conversations",
            "default": 0
          },
          "messages": {
            "type": "integer",
            "title": "Messages",
            "default": 0
          },
          "response_rate": {
            "type": "number",
            "title": "Response Rate",
            "default": 0.0
          }
        },
        "type": "object",
        "required": [
          "assistant_id",
          "assistant_name"
        ],
        "title": "ChatAssistantBreakdown",
        "description": "Per-assistant performance metrics."
      },
      "ChatDailyTrend": {
        "properties": {
          "date": {
            "type": "string",
            "title": "Date"
          },
          "conversations": {
            "type": "integer",
            "title": "Conversations",
            "default": 0
          },
          "messages": {
            "type": "integer",
            "title": "Messages",
            "default": 0
          },
          "ai_messages": {
            "type": "integer",
            "title": "Ai Messages",
            "default": 0
          }
        },
        "type": "object",
        "required": [
          "date"
        ],
        "title": "ChatDailyTrend",
        "description": "A single day's activity for the daily trend chart."
      },
      "ChatMessage": {
        "properties": {
          "role": {
            "type": "string",
            "enum": [
              "user",
              "assistant",
              "system"
            ],
            "title": "Role",
            "description": "Message role"
          },
          "content": {
            "type": "string",
            "title": "Content",
            "description": "Message content"
          }
        },
        "type": "object",
        "required": [
          "role",
          "content"
        ],
        "title": "ChatMessage",
        "description": "Single chat message in a conversation."
      },
      "ChatStatsResponse": {
        "properties": {
          "total_conversations": {
            "type": "integer",
            "title": "Total Conversations",
            "default": 0
          },
          "total_messages": {
            "type": "integer",
            "title": "Total Messages",
            "default": 0
          },
          "total_ai_messages": {
            "type": "integer",
            "title": "Total Ai Messages",
            "default": 0
          },
          "total_contact_messages": {
            "type": "integer",
            "title": "Total Contact Messages",
            "default": 0
          },
          "total_human_messages": {
            "type": "integer",
            "title": "Total Human Messages",
            "default": 0
          },
          "actions_triggered": {
            "type": "integer",
            "title": "Actions Triggered",
            "default": 0
          },
          "appointments_booked": {
            "type": "integer",
            "title": "Appointments Booked",
            "default": 0
          },
          "active_conversations": {
            "type": "integer",
            "title": "Active Conversations",
            "default": 0
          },
          "channels": {
            "additionalProperties": {
              "type": "integer"
            },
            "type": "object",
            "title": "Channels",
            "default": {}
          },
          "time_saved_minutes": {
            "type": "number",
            "title": "Time Saved Minutes",
            "default": 0.0
          },
          "response_rate": {
            "type": "number",
            "title": "Response Rate",
            "default": 0.0
          },
          "avg_messages_per_conversation": {
            "type": "number",
            "title": "Avg Messages Per Conversation",
            "default": 0.0
          },
          "human_takeover_rate": {
            "type": "number",
            "title": "Human Takeover Rate",
            "default": 0.0
          },
          "daily_trend": {
            "items": {
              "$ref": "#/components/schemas/ChatDailyTrend"
            },
            "type": "array",
            "title": "Daily Trend",
            "default": []
          },
          "assistant_breakdown": {
            "items": {
              "$ref": "#/components/schemas/ChatAssistantBreakdown"
            },
            "type": "array",
            "title": "Assistant Breakdown",
            "default": []
          }
        },
        "type": "object",
        "title": "ChatStatsResponse",
        "description": "Response schema for chat dashboard statistics."
      },
      "CheckSlugRequest": {
        "properties": {
          "slug": {
            "type": "string",
            "maxLength": 50,
            "minLength": 1,
            "pattern": "^[a-z0-9-]+$",
            "title": "Slug"
          }
        },
        "type": "object",
        "required": [
          "slug"
        ],
        "title": "CheckSlugRequest",
        "description": "Request to check if a slug is available."
      },
      "CheckSlugResponse": {
        "properties": {
          "available": {
            "type": "boolean",
            "title": "Available"
          },
          "slug": {
            "type": "string",
            "title": "Slug"
          },
          "message": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Message"
          }
        },
        "type": "object",
        "required": [
          "available",
          "slug"
        ],
        "title": "CheckSlugResponse",
        "description": "Response for slug availability check."
      },
      "CheckoutRequest": {
        "properties": {
          "plan": {
            "type": "string",
            "enum": [
              "payg",
              "starter",
              "agency",
              "pro"
            ],
            "title": "Plan"
          },
          "billing_period": {
            "type": "string",
            "enum": [
              "monthly",
              "annual"
            ],
            "title": "Billing Period",
            "default": "monthly"
          },
          "success_url": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Success Url"
          },
          "cancel_url": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Cancel Url"
          }
        },
        "type": "object",
        "required": [
          "plan"
        ],
        "title": "CheckoutRequest",
        "description": "Request to create a Stripe Checkout session."
      },
      "CheckoutResponse": {
        "properties": {
          "checkout_url": {
            "type": "string",
            "title": "Checkout Url"
          }
        },
        "type": "object",
        "required": [
          "checkout_url"
        ],
        "title": "CheckoutResponse",
        "description": "Response containing Stripe Checkout URL."
      },
      "ClientBillingUpdateRequest": {
        "properties": {
          "enabled": {
            "type": "boolean",
            "title": "Enabled"
          },
          "billing_email": {
            "anyOf": [
              {
                "type": "string",
                "format": "email"
              },
              {
                "type": "null"
              }
            ],
            "title": "Billing Email"
          }
        },
        "type": "object",
        "required": [
          "enabled"
        ],
        "title": "ClientBillingUpdateRequest"
      },
      "CollectionStatsResponse": {
        "properties": {
          "collection_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "title": "Collection Id"
          },
          "xai_collection_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Xai Collection Id"
          },
          "name": {
            "type": "string",
            "title": "Name",
            "default": "Knowledge Base"
          },
          "document_count": {
            "type": "integer",
            "title": "Document Count",
            "default": 0
          },
          "total_bytes": {
            "type": "integer",
            "title": "Total Bytes",
            "default": 0
          },
          "documents_ready": {
            "type": "integer",
            "title": "Documents Ready",
            "default": 0
          },
          "documents_processing": {
            "type": "integer",
            "title": "Documents Processing",
            "default": 0
          },
          "documents_failed": {
            "type": "integer",
            "title": "Documents Failed",
            "default": 0
          }
        },
        "type": "object",
        "title": "CollectionStatsResponse",
        "description": "Collection statistics response."
      },
      "ContactDetail": {
        "properties": {
          "id": {
            "type": "string",
            "title": "Id"
          },
          "first_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "First Name"
          },
          "last_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Last Name"
          },
          "phone": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Phone"
          },
          "email": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Email"
          },
          "company": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Company"
          },
          "tags": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Tags",
            "default": []
          },
          "calls": {
            "items": {
              "$ref": "#/components/schemas/CallHistorySummary"
            },
            "type": "array",
            "title": "Calls",
            "default": []
          },
          "total_calls": {
            "type": "integer",
            "title": "Total Calls",
            "default": 0
          },
          "stats": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/ContactStats"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "type": "object",
        "required": [
          "id"
        ],
        "title": "ContactDetail",
        "description": "Full contact detail with call history."
      },
      "ContactDetailResponse": {
        "properties": {
          "contact": {
            "$ref": "#/components/schemas/ContactDetail"
          }
        },
        "type": "object",
        "required": [
          "contact"
        ],
        "title": "ContactDetailResponse",
        "description": "Single contact with full call history."
      },
      "ContactIntelligencePromptRequest": {
        "properties": {
          "current_prompt": {
            "type": "string",
            "maxLength": 50000,
            "minLength": 10,
            "title": "Current Prompt",
            "description": "The existing system prompt to modify"
          },
          "action": {
            "type": "string",
            "pattern": "^(add|remove)$",
            "title": "Action",
            "description": "Action to perform: 'add' to inject CI section, 'remove' to strip it"
          }
        },
        "type": "object",
        "required": [
          "current_prompt",
          "action"
        ],
        "title": "ContactIntelligencePromptRequest",
        "description": "Request to update prompt with Contact Intelligence instructions."
      },
      "ContactListItem": {
        "properties": {
          "id": {
            "type": "string",
            "title": "Id"
          },
          "first_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "First Name"
          },
          "last_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Last Name"
          },
          "phone": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Phone"
          },
          "email": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Email"
          },
          "company": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Company"
          },
          "tags": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Tags",
            "default": []
          },
          "total_calls": {
            "type": "integer",
            "title": "Total Calls",
            "default": 0
          },
          "last_call_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Last Call At"
          }
        },
        "type": "object",
        "required": [
          "id"
        ],
        "title": "ContactListItem",
        "description": "Contact in the list view."
      },
      "ContactListResponse": {
        "properties": {
          "contacts": {
            "items": {
              "$ref": "#/components/schemas/ContactListItem"
            },
            "type": "array",
            "title": "Contacts"
          },
          "total": {
            "type": "integer",
            "title": "Total"
          },
          "next_cursor": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Next Cursor"
          },
          "next_cursor_timestamp": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Next Cursor Timestamp"
          },
          "has_more": {
            "type": "boolean",
            "title": "Has More",
            "default": false
          }
        },
        "type": "object",
        "required": [
          "contacts",
          "total"
        ],
        "title": "ContactListResponse",
        "description": "Paginated contact list response."
      },
      "ContactPatchRequest": {
        "properties": {
          "add_tags": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Add Tags",
            "default": []
          },
          "remove_tags": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Remove Tags",
            "default": []
          },
          "custom_fields": {
            "anyOf": [
              {
                "items": {
                  "additionalProperties": true,
                  "type": "object"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Custom Fields"
          },
          "opportunity_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Opportunity Id"
          },
          "pipeline_stage_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Pipeline Stage Id"
          }
        },
        "type": "object",
        "title": "ContactPatchRequest",
        "description": "Request to update a GHL contact."
      },
      "ContactPatchResponse": {
        "properties": {
          "success": {
            "type": "boolean",
            "title": "Success"
          },
          "tags_added": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Tags Added",
            "default": []
          },
          "tags_removed": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Tags Removed",
            "default": []
          },
          "fields_updated": {
            "type": "boolean",
            "title": "Fields Updated",
            "default": false
          },
          "stage_updated": {
            "type": "boolean",
            "title": "Stage Updated",
            "default": false
          }
        },
        "type": "object",
        "required": [
          "success"
        ],
        "title": "ContactPatchResponse",
        "description": "Result of a contact patch operation."
      },
      "ContactStats": {
        "properties": {
          "total_calls": {
            "type": "integer",
            "title": "Total Calls",
            "default": 0
          },
          "avg_duration_seconds": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "title": "Avg Duration Seconds"
          },
          "appointments_booked": {
            "type": "integer",
            "title": "Appointments Booked",
            "default": 0
          },
          "last_call_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Last Call At"
          }
        },
        "type": "object",
        "title": "ContactStats",
        "description": "Aggregate stats for a contact's call history."
      },
      "ContactSupportRequest": {
        "properties": {
          "subject": {
            "type": "string",
            "maxLength": 200,
            "minLength": 1,
            "title": "Subject"
          },
          "message": {
            "type": "string",
            "maxLength": 5000,
            "minLength": 1,
            "title": "Message"
          }
        },
        "type": "object",
        "required": [
          "subject",
          "message"
        ],
        "title": "ContactSupportRequest"
      },
      "ContactSupportResponse": {
        "properties": {
          "status": {
            "type": "string",
            "title": "Status"
          },
          "reply_to": {
            "type": "string",
            "title": "Reply To"
          }
        },
        "type": "object",
        "required": [
          "status",
          "reply_to"
        ],
        "title": "ContactSupportResponse"
      },
      "ConversationEvent": {
        "properties": {
          "id": {
            "type": "string",
            "title": "Id"
          },
          "event_type": {
            "type": "string",
            "title": "Event Type"
          },
          "direction": {
            "type": "string",
            "title": "Direction"
          },
          "occurred_at": {
            "type": "string",
            "format": "date-time",
            "title": "Occurred At"
          },
          "duration_seconds": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Duration Seconds"
          },
          "status": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Status"
          },
          "summary": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Summary"
          },
          "agent_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Agent Name"
          },
          "content": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Content"
          },
          "channel": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Channel"
          }
        },
        "type": "object",
        "required": [
          "id",
          "event_type",
          "direction",
          "occurred_at"
        ],
        "title": "ConversationEvent",
        "description": "A single event in the conversation timeline (call or SMS)."
      },
      "ConversationTimelineResponse": {
        "properties": {
          "contact_phone": {
            "type": "string",
            "title": "Contact Phone"
          },
          "events": {
            "items": {
              "$ref": "#/components/schemas/ConversationEvent"
            },
            "type": "array",
            "title": "Events"
          },
          "total": {
            "type": "integer",
            "title": "Total"
          },
          "sms_included": {
            "type": "boolean",
            "title": "Sms Included"
          }
        },
        "type": "object",
        "required": [
          "contact_phone",
          "events",
          "total",
          "sms_included"
        ],
        "title": "ConversationTimelineResponse",
        "description": "Merged call + SMS timeline for a contact."
      },
      "CopyAgentToSubAccountRequest": {
        "properties": {
          "source_tenant_id": {
            "type": "string",
            "format": "uuid",
            "title": "Source Tenant Id"
          },
          "target_tenant_id": {
            "type": "string",
            "format": "uuid",
            "title": "Target Tenant Id"
          }
        },
        "type": "object",
        "required": [
          "source_tenant_id",
          "target_tenant_id"
        ],
        "title": "CopyAgentToSubAccountRequest",
        "description": "Request body for copying an agent between sub-accounts."
      },
      "CopyFunctionRequest": {
        "properties": {
          "target_tenant_id": {
            "type": "string",
            "format": "uuid",
            "title": "Target Tenant Id",
            "description": "Target sub-account to copy function to"
          }
        },
        "type": "object",
        "required": [
          "target_tenant_id"
        ],
        "title": "CopyFunctionRequest",
        "description": "Request to copy a function to another sub-account (agency feature)."
      },
      "CostByDirection": {
        "properties": {
          "direction": {
            "type": "string",
            "title": "Direction"
          },
          "calls": {
            "type": "integer",
            "title": "Calls"
          },
          "minutes": {
            "type": "integer",
            "title": "Minutes"
          },
          "cost_cents": {
            "type": "integer",
            "title": "Cost Cents"
          },
          "revenue_cents": {
            "type": "integer",
            "title": "Revenue Cents"
          },
          "margin_cents": {
            "type": "integer",
            "title": "Margin Cents"
          }
        },
        "type": "object",
        "required": [
          "direction",
          "calls",
          "minutes",
          "cost_cents",
          "revenue_cents",
          "margin_cents"
        ],
        "title": "CostByDirection",
        "description": "Cost breakdown by call direction/type."
      },
      "CostByProvider": {
        "properties": {
          "provider": {
            "type": "string",
            "title": "Provider"
          },
          "provider_label": {
            "type": "string",
            "title": "Provider Label"
          },
          "calls": {
            "type": "integer",
            "title": "Calls"
          },
          "minutes": {
            "type": "integer",
            "title": "Minutes"
          },
          "cost_cents": {
            "type": "integer",
            "title": "Cost Cents"
          },
          "revenue_cents": {
            "type": "integer",
            "title": "Revenue Cents"
          },
          "margin_cents": {
            "type": "integer",
            "title": "Margin Cents"
          }
        },
        "type": "object",
        "required": [
          "provider",
          "provider_label",
          "calls",
          "minutes",
          "cost_cents",
          "revenue_cents",
          "margin_cents"
        ],
        "title": "CostByProvider",
        "description": "Cost breakdown by voice provider."
      },
      "CreateShareLinkRequest": {
        "properties": {
          "custom_slug": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Custom Slug"
          },
          "expires_in_days": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Expires In Days"
          }
        },
        "type": "object",
        "title": "CreateShareLinkRequest",
        "description": "Request to create a shareable link."
      },
      "CreateShareLinkResponse": {
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "title": "Id"
          },
          "slug": {
            "type": "string",
            "title": "Slug"
          },
          "share_url": {
            "type": "string",
            "title": "Share Url"
          },
          "is_active": {
            "type": "boolean",
            "title": "Is Active"
          },
          "expires_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Expires At"
          }
        },
        "type": "object",
        "required": [
          "id",
          "slug",
          "share_url",
          "is_active"
        ],
        "title": "CreateShareLinkResponse",
        "description": "Response after creating a share link."
      },
      "CreateSubAccountRequest": {
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 100,
            "minLength": 1,
            "title": "Name"
          },
          "slug": {
            "type": "string",
            "maxLength": 50,
            "minLength": 2,
            "pattern": "^[a-z0-9-]+$",
            "title": "Slug"
          },
          "admin_email": {
            "anyOf": [
              {
                "type": "string",
                "format": "email"
              },
              {
                "type": "null"
              }
            ],
            "title": "Admin Email"
          },
          "admin_name": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 100
              },
              {
                "type": "null"
              }
            ],
            "title": "Admin Name"
          },
          "per_minute_rate_cents": {
            "type": "integer",
            "maximum": 1000.0,
            "minimum": 0.0,
            "title": "Per Minute Rate Cents",
            "default": 20
          },
          "monthly_platform_fee_cents": {
            "type": "integer",
            "minimum": 0.0,
            "title": "Monthly Platform Fee Cents",
            "default": 0
          },
          "billing_start_day": {
            "type": "integer",
            "maximum": 28.0,
            "minimum": 1.0,
            "title": "Billing Start Day",
            "default": 1
          },
          "upcharge_by_provider": {
            "anyOf": [
              {
                "additionalProperties": {
                  "type": "integer"
                },
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Upcharge By Provider"
          },
          "test_demo_upcharge_by_provider": {
            "anyOf": [
              {
                "additionalProperties": {
                  "type": "integer"
                },
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Test Demo Upcharge By Provider"
          },
          "text_upcharge_by_type": {
            "anyOf": [
              {
                "additionalProperties": {
                  "type": "integer"
                },
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Text Upcharge By Type"
          }
        },
        "type": "object",
        "required": [
          "name",
          "slug"
        ],
        "title": "CreateSubAccountRequest",
        "description": "Request to create a new sub-account."
      },
      "CustomFunctionCreate": {
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 100,
            "minLength": 2,
            "title": "Name",
            "description": "Function name in snake_case (e.g., check_inventory)"
          },
          "description": {
            "type": "string",
            "maxLength": 1000,
            "minLength": 10,
            "title": "Description",
            "description": "Description of what the function does (shown to AI)"
          },
          "parameters": {
            "additionalProperties": true,
            "type": "object",
            "title": "Parameters",
            "description": "JSON Schema for function parameters"
          },
          "webhook_url": {
            "type": "string",
            "maxLength": 2000,
            "minLength": 10,
            "title": "Webhook Url",
            "description": "Webhook URL to call (must start with http:// or https://)"
          },
          "webhook_method": {
            "type": "string",
            "title": "Webhook Method",
            "description": "HTTP method for webhook call",
            "default": "POST"
          },
          "webhook_headers": {
            "additionalProperties": {
              "type": "string"
            },
            "type": "object",
            "title": "Webhook Headers",
            "description": "Custom headers to include in webhook request"
          },
          "webhook_timeout_ms": {
            "type": "integer",
            "maximum": 30000.0,
            "minimum": 1000.0,
            "title": "Webhook Timeout Ms",
            "description": "Timeout for webhook call in milliseconds (1000-30000)",
            "default": 5000
          },
          "is_enabled": {
            "type": "boolean",
            "title": "Is Enabled",
            "description": "Whether the function is enabled",
            "default": true
          },
          "speak_during_execution": {
            "type": "boolean",
            "title": "Speak During Execution",
            "description": "Whether AI should speak while waiting for webhook response",
            "default": true
          }
        },
        "type": "object",
        "required": [
          "name",
          "description",
          "webhook_url"
        ],
        "title": "CustomFunctionCreate",
        "description": "Request body for creating a custom function."
      },
      "CustomFunctionResponse": {
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "title": "Id"
          },
          "tenant_id": {
            "type": "string",
            "format": "uuid",
            "title": "Tenant Id"
          },
          "agent_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "title": "Agent Id"
          },
          "name": {
            "type": "string",
            "title": "Name"
          },
          "description": {
            "type": "string",
            "title": "Description"
          },
          "parameters": {
            "additionalProperties": true,
            "type": "object",
            "title": "Parameters"
          },
          "webhook_url": {
            "type": "string",
            "title": "Webhook Url"
          },
          "webhook_method": {
            "type": "string",
            "title": "Webhook Method"
          },
          "webhook_headers": {
            "additionalProperties": {
              "type": "string"
            },
            "type": "object",
            "title": "Webhook Headers"
          },
          "webhook_timeout_ms": {
            "type": "integer",
            "title": "Webhook Timeout Ms"
          },
          "is_enabled": {
            "type": "boolean",
            "title": "Is Enabled"
          },
          "speak_during_execution": {
            "type": "boolean",
            "title": "Speak During Execution"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "title": "Created At"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "title": "Updated At"
          }
        },
        "type": "object",
        "required": [
          "id",
          "tenant_id",
          "name",
          "description",
          "parameters",
          "webhook_url",
          "webhook_method",
          "webhook_headers",
          "webhook_timeout_ms",
          "is_enabled",
          "speak_during_execution",
          "created_at",
          "updated_at"
        ],
        "title": "CustomFunctionResponse",
        "description": "Response schema for custom function data."
      },
      "CustomFunctionUpdate": {
        "properties": {
          "name": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 100,
                "minLength": 2
              },
              {
                "type": "null"
              }
            ],
            "title": "Name",
            "description": "Function name in snake_case"
          },
          "description": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 1000,
                "minLength": 10
              },
              {
                "type": "null"
              }
            ],
            "title": "Description",
            "description": "Description of what the function does"
          },
          "parameters": {
            "anyOf": [
              {
                "additionalProperties": true,
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Parameters",
            "description": "JSON Schema for function parameters"
          },
          "webhook_url": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 2000,
                "minLength": 10
              },
              {
                "type": "null"
              }
            ],
            "title": "Webhook Url",
            "description": "Webhook URL to call"
          },
          "webhook_method": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Webhook Method",
            "description": "HTTP method for webhook call"
          },
          "webhook_headers": {
            "anyOf": [
              {
                "additionalProperties": {
                  "type": "string"
                },
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Webhook Headers",
            "description": "Custom headers to include in webhook request"
          },
          "webhook_timeout_ms": {
            "anyOf": [
              {
                "type": "integer",
                "maximum": 30000.0,
                "minimum": 1000.0
              },
              {
                "type": "null"
              }
            ],
            "title": "Webhook Timeout Ms",
            "description": "Timeout for webhook call in milliseconds"
          },
          "is_enabled": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Is Enabled",
            "description": "Whether the function is enabled"
          },
          "speak_during_execution": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Speak During Execution",
            "description": "Whether AI should speak while waiting for webhook response"
          }
        },
        "type": "object",
        "title": "CustomFunctionUpdate",
        "description": "Request body for updating a custom function. All fields optional."
      },
      "DailyAgencyTrend": {
        "properties": {
          "date": {
            "type": "string",
            "title": "Date"
          },
          "calls": {
            "type": "integer",
            "title": "Calls"
          },
          "minutes": {
            "type": "number",
            "title": "Minutes"
          },
          "revenue_cents": {
            "type": "integer",
            "title": "Revenue Cents"
          },
          "cost_cents": {
            "type": "integer",
            "title": "Cost Cents"
          },
          "margin_cents": {
            "type": "integer",
            "title": "Margin Cents"
          }
        },
        "type": "object",
        "required": [
          "date",
          "calls",
          "minutes",
          "revenue_cents",
          "cost_cents",
          "margin_cents"
        ],
        "title": "DailyAgencyTrend",
        "description": "Daily aggregated stats for trend chart."
      },
      "DailyTrend": {
        "properties": {
          "date": {
            "type": "string",
            "format": "date",
            "title": "Date"
          },
          "calls": {
            "type": "integer",
            "title": "Calls",
            "default": 0
          },
          "minutes": {
            "type": "number",
            "title": "Minutes",
            "default": 0.0
          },
          "cost_cents": {
            "type": "integer",
            "title": "Cost Cents",
            "default": 0
          },
          "booked": {
            "type": "integer",
            "title": "Booked",
            "default": 0
          }
        },
        "type": "object",
        "required": [
          "date"
        ],
        "title": "DailyTrend",
        "description": "One row per day in the selected range."
      },
      "DashboardStats": {
        "properties": {
          "total_calls": {
            "type": "integer",
            "title": "Total Calls"
          },
          "total_minutes": {
            "type": "number",
            "title": "Total Minutes"
          },
          "active_agents": {
            "type": "integer",
            "title": "Active Agents"
          },
          "conversion_rate": {
            "type": "number",
            "title": "Conversion Rate"
          },
          "recent_calls": {
            "items": {
              "$ref": "#/components/schemas/RecentCall"
            },
            "type": "array",
            "title": "Recent Calls"
          },
          "usage_trend": {
            "additionalProperties": {
              "type": "number"
            },
            "type": "object",
            "title": "Usage Trend"
          },
          "period_start": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Period Start"
          },
          "period_end": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Period End"
          },
          "period_source": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Period Source"
          },
          "billable_minutes": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "title": "Billable Minutes"
          },
          "billable_calls": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Billable Calls"
          },
          "call_attempts": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Call Attempts"
          }
        },
        "type": "object",
        "required": [
          "total_calls",
          "total_minutes",
          "active_agents",
          "conversion_rate",
          "recent_calls",
          "usage_trend"
        ],
        "title": "DashboardStats",
        "description": "Schema for dashboard statistics response."
      },
      "DefaultSubAccountResponse": {
        "properties": {
          "created": {
            "type": "boolean",
            "title": "Created"
          },
          "sub_account": {
            "$ref": "#/components/schemas/SubAccountResponse"
          }
        },
        "type": "object",
        "required": [
          "created",
          "sub_account"
        ],
        "title": "DefaultSubAccountResponse",
        "description": "POST /agency/sub-accounts/default (DAN-467).\n\ncreated is False when the agency already had an active sub-account and that\none is returned instead, so the call is safe to repeat."
      },
      "DeletionRequestPayload": {
        "properties": {
          "reason": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 1000
              },
              {
                "type": "null"
              }
            ],
            "title": "Reason"
          }
        },
        "type": "object",
        "title": "DeletionRequestPayload"
      },
      "DemoChatMessage": {
        "properties": {
          "role": {
            "type": "string",
            "pattern": "^(user|assistant)$",
            "title": "Role"
          },
          "content": {
            "type": "string",
            "title": "Content"
          }
        },
        "type": "object",
        "required": [
          "role",
          "content"
        ],
        "title": "DemoChatMessage",
        "description": "A single message in a demo chat conversation."
      },
      "DemoChatRequest": {
        "properties": {
          "messages": {
            "items": {
              "$ref": "#/components/schemas/DemoChatMessage"
            },
            "type": "array",
            "maxItems": 100,
            "minItems": 1,
            "title": "Messages"
          },
          "dynamic_variables": {
            "anyOf": [
              {
                "additionalProperties": {
                  "type": "string"
                },
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Dynamic Variables"
          }
        },
        "type": "object",
        "required": [
          "messages"
        ],
        "title": "DemoChatRequest",
        "description": "Request to send a message in a demo text chat."
      },
      "DemoChatResponse": {
        "properties": {
          "messages": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Messages"
          },
          "greeting": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Greeting"
          }
        },
        "type": "object",
        "required": [
          "messages"
        ],
        "title": "DemoChatResponse",
        "description": "Response from the demo text chat endpoint."
      },
      "DemoConfigCreate": {
        "properties": {
          "agent_id": {
            "type": "string",
            "format": "uuid",
            "title": "Agent Id"
          },
          "channel": {
            "type": "string",
            "enum": [
              "phone",
              "sms",
              "web",
              "orb",
              "fb_messenger",
              "ig_messenger",
              "tiktok",
              "whatsapp",
              "fb_lead",
              "ig_lead"
            ],
            "title": "Channel"
          },
          "name": {
            "type": "string",
            "title": "Name"
          },
          "config": {
            "additionalProperties": true,
            "type": "object",
            "title": "Config",
            "default": {}
          },
          "after_cta_text": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "After Cta Text"
          },
          "after_cta_url": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "After Cta Url"
          },
          "webhook_url": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Webhook Url"
          },
          "expires_in_days": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Expires In Days"
          }
        },
        "type": "object",
        "required": [
          "agent_id",
          "channel",
          "name"
        ],
        "title": "DemoConfigCreate",
        "description": "Request to create a demo config."
      },
      "DemoConfigListItem": {
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "title": "Id"
          },
          "name": {
            "type": "string",
            "title": "Name"
          },
          "channel": {
            "type": "string",
            "title": "Channel"
          },
          "agent_name": {
            "type": "string",
            "title": "Agent Name",
            "default": "Unknown Agent"
          },
          "slug": {
            "type": "string",
            "title": "Slug"
          },
          "config": {
            "additionalProperties": true,
            "type": "object",
            "title": "Config",
            "default": {}
          },
          "is_active": {
            "type": "boolean",
            "title": "Is Active",
            "default": true
          },
          "view_count": {
            "type": "integer",
            "title": "View Count",
            "default": 0
          },
          "call_count": {
            "type": "integer",
            "title": "Call Count",
            "default": 0
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "title": "Created At"
          },
          "expires_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Expires At"
          }
        },
        "type": "object",
        "required": [
          "id",
          "name",
          "channel",
          "slug",
          "created_at"
        ],
        "title": "DemoConfigListItem",
        "description": "Summary for the demo management grid."
      },
      "DemoConfigResponse": {
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "title": "Id"
          },
          "agent_id": {
            "type": "string",
            "format": "uuid",
            "title": "Agent Id"
          },
          "tenant_id": {
            "type": "string",
            "format": "uuid",
            "title": "Tenant Id"
          },
          "slug": {
            "type": "string",
            "title": "Slug"
          },
          "name": {
            "type": "string",
            "title": "Name"
          },
          "channel": {
            "type": "string",
            "title": "Channel"
          },
          "config": {
            "additionalProperties": true,
            "type": "object",
            "title": "Config",
            "default": {}
          },
          "is_active": {
            "type": "boolean",
            "title": "Is Active",
            "default": true
          },
          "view_count": {
            "type": "integer",
            "title": "View Count",
            "default": 0
          },
          "call_count": {
            "type": "integer",
            "title": "Call Count",
            "default": 0
          },
          "demo_url": {
            "type": "string",
            "title": "Demo Url",
            "default": ""
          },
          "after_cta_text": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "After Cta Text"
          },
          "after_cta_url": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "After Cta Url"
          },
          "webhook_url": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Webhook Url"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "title": "Created At"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "title": "Updated At"
          },
          "expires_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Expires At"
          }
        },
        "type": "object",
        "required": [
          "id",
          "agent_id",
          "tenant_id",
          "slug",
          "name",
          "channel",
          "created_at",
          "updated_at"
        ],
        "title": "DemoConfigResponse",
        "description": "Full demo config response."
      },
      "DemoConfigUpdate": {
        "properties": {
          "name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Name"
          },
          "channel": {
            "anyOf": [
              {
                "type": "string",
                "enum": [
                  "phone",
                  "sms",
                  "web",
                  "orb",
                  "fb_messenger",
                  "ig_messenger",
                  "tiktok",
                  "whatsapp",
                  "fb_lead",
                  "ig_lead"
                ]
              },
              {
                "type": "null"
              }
            ],
            "title": "Channel"
          },
          "config": {
            "anyOf": [
              {
                "additionalProperties": true,
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Config"
          },
          "is_active": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Is Active"
          },
          "after_cta_text": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "After Cta Text"
          },
          "after_cta_url": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "After Cta Url"
          },
          "webhook_url": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Webhook Url"
          },
          "expires_in_days": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Expires In Days"
          }
        },
        "type": "object",
        "title": "DemoConfigUpdate",
        "description": "Request to update a demo config (all optional)."
      },
      "DemoEventCreate": {
        "properties": {
          "event_type": {
            "type": "string",
            "title": "Event Type"
          },
          "duration_s": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Duration S"
          },
          "metadata": {
            "additionalProperties": true,
            "type": "object",
            "title": "Metadata",
            "default": {}
          }
        },
        "type": "object",
        "required": [
          "event_type"
        ],
        "title": "DemoEventCreate",
        "description": "Request to track a demo event."
      },
      "DirectionBreakdown": {
        "properties": {
          "direction": {
            "type": "string",
            "title": "Direction"
          },
          "count": {
            "type": "integer",
            "title": "Count",
            "default": 0
          }
        },
        "type": "object",
        "required": [
          "direction"
        ],
        "title": "DirectionBreakdown",
        "description": "Call count grouped by direction."
      },
      "DocumentListResponse": {
        "properties": {
          "documents": {
            "items": {
              "$ref": "#/components/schemas/DocumentResponse"
            },
            "type": "array",
            "title": "Documents"
          },
          "total": {
            "type": "integer",
            "title": "Total"
          }
        },
        "type": "object",
        "required": [
          "documents",
          "total"
        ],
        "title": "DocumentListResponse",
        "description": "List of documents response."
      },
      "DocumentResponse": {
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "title": "Id"
          },
          "tenant_id": {
            "type": "string",
            "format": "uuid",
            "title": "Tenant Id"
          },
          "collection_id": {
            "type": "string",
            "format": "uuid",
            "title": "Collection Id"
          },
          "xai_document_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Xai Document Id"
          },
          "filename": {
            "type": "string",
            "title": "Filename"
          },
          "content_type": {
            "type": "string",
            "title": "Content Type"
          },
          "file_size": {
            "type": "integer",
            "title": "File Size"
          },
          "status": {
            "type": "string",
            "title": "Status"
          },
          "error_message": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Error Message"
          },
          "description": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Description"
          },
          "source_type": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Source Type"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "title": "Created At"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "title": "Updated At"
          }
        },
        "type": "object",
        "required": [
          "id",
          "tenant_id",
          "collection_id",
          "filename",
          "content_type",
          "file_size",
          "status",
          "created_at",
          "updated_at"
        ],
        "title": "DocumentResponse",
        "description": "Document data response."
      },
      "EmbedSSORequest": {
        "properties": {
          "payload": {
            "type": "string",
            "minLength": 1,
            "title": "Payload",
            "description": "Encrypted SSO payload from partner platform"
          }
        },
        "type": "object",
        "required": [
          "payload"
        ],
        "title": "EmbedSSORequest",
        "description": "Request body for embedded SSO endpoint."
      },
      "EmotionTagItem": {
        "properties": {
          "name": {
            "type": "string",
            "title": "Name"
          },
          "description": {
            "type": "string",
            "title": "Description"
          }
        },
        "type": "object",
        "required": [
          "name",
          "description"
        ],
        "title": "EmotionTagItem",
        "description": "An emotion tag with name and description."
      },
      "EnabledChannels": {
        "properties": {
          "sms": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "$ref": "#/components/schemas/ChannelConfig"
              }
            ],
            "title": "Sms",
            "default": true
          },
          "whatsapp": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "$ref": "#/components/schemas/ChannelConfig"
              }
            ],
            "title": "Whatsapp",
            "default": true
          },
          "instagram": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "$ref": "#/components/schemas/ChannelConfig"
              }
            ],
            "title": "Instagram",
            "default": true
          },
          "facebook": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "$ref": "#/components/schemas/ChannelConfig"
              }
            ],
            "title": "Facebook",
            "default": true
          },
          "tiktok": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "$ref": "#/components/schemas/ChannelConfig"
              }
            ],
            "title": "Tiktok",
            "default": true
          },
          "live_chat": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "$ref": "#/components/schemas/ChannelConfig"
              }
            ],
            "title": "Live Chat",
            "default": true
          }
        },
        "type": "object",
        "title": "EnabledChannels",
        "description": "Per-channel AI enable/disable settings.\n\nSupports both legacy boolean format and new ChannelConfig format:\n- Legacy: {\"sms\": true, \"instagram\": false}\n- New: {\"sms\": {\"enabled\": true, \"accounts\": []}, \"instagram\": {\"enabled\": true, \"accounts\": [\"@mybusiness\"]}}"
      },
      "EnhanceDescriptionRequest": {
        "properties": {
          "business_name": {
            "type": "string",
            "maxLength": 100,
            "minLength": 1,
            "title": "Business Name"
          },
          "industry": {
            "type": "string",
            "maxLength": 50,
            "minLength": 1,
            "title": "Industry"
          },
          "description": {
            "type": "string",
            "maxLength": 500,
            "minLength": 10,
            "title": "Description"
          }
        },
        "type": "object",
        "required": [
          "business_name",
          "industry",
          "description"
        ],
        "title": "EnhanceDescriptionRequest",
        "description": "Request to enhance a business description."
      },
      "EnhanceDescriptionResponse": {
        "properties": {
          "enhanced_description": {
            "type": "string",
            "title": "Enhanced Description"
          }
        },
        "type": "object",
        "required": [
          "enhanced_description"
        ],
        "title": "EnhanceDescriptionResponse",
        "description": "Response with enhanced description."
      },
      "EnrichedContactDetail": {
        "properties": {
          "id": {
            "type": "string",
            "title": "Id"
          },
          "first_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "First Name"
          },
          "last_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Last Name"
          },
          "phone": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Phone"
          },
          "email": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Email"
          },
          "company": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Company"
          },
          "tags": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Tags",
            "default": []
          },
          "calls": {
            "items": {
              "$ref": "#/components/schemas/CallHistorySummary"
            },
            "type": "array",
            "title": "Calls",
            "default": []
          },
          "total_calls": {
            "type": "integer",
            "title": "Total Calls",
            "default": 0
          },
          "stats": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/ContactStats"
              },
              {
                "type": "null"
              }
            ]
          },
          "pipeline_stage": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Pipeline Stage"
          },
          "pipeline_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Pipeline Name"
          },
          "deal_value": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "title": "Deal Value"
          },
          "custom_fields": {
            "additionalProperties": {
              "type": "string"
            },
            "type": "object",
            "title": "Custom Fields",
            "default": {}
          },
          "upcoming_appointments": {
            "items": {
              "$ref": "#/components/schemas/AppointmentEntry"
            },
            "type": "array",
            "title": "Upcoming Appointments",
            "default": []
          },
          "past_appointments": {
            "items": {
              "$ref": "#/components/schemas/AppointmentEntry"
            },
            "type": "array",
            "title": "Past Appointments",
            "default": []
          }
        },
        "type": "object",
        "required": [
          "id"
        ],
        "title": "EnrichedContactDetail",
        "description": "Extended contact detail with GHL pipeline + custom field enrichment."
      },
      "EnrichedContactDetailResponse": {
        "properties": {
          "contact": {
            "$ref": "#/components/schemas/EnrichedContactDetail"
          }
        },
        "type": "object",
        "required": [
          "contact"
        ],
        "title": "EnrichedContactDetailResponse",
        "description": "Single contact with enriched GHL data."
      },
      "EnrollmentCreate": {
        "properties": {
          "contact_phone": {
            "type": "string",
            "pattern": "^\\+[1-9]\\d{1,14}$",
            "title": "Contact Phone",
            "description": "E.164 format"
          },
          "contact_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Contact Name"
          },
          "contact_email": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Contact Email"
          },
          "contact_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Contact Id"
          },
          "timezone": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Timezone",
            "description": "IANA timezone for this contact. Leave empty to use the sequence timezone."
          },
          "variables": {
            "additionalProperties": {
              "type": "string"
            },
            "type": "object",
            "title": "Variables",
            "description": "Dynamic merge variables for copy (e.g. first_name, company, website). Source-agnostic: CSV mapping or GHL webhook body populate this."
          }
        },
        "type": "object",
        "required": [
          "contact_phone"
        ],
        "title": "EnrollmentCreate"
      },
      "EnrollmentListResponse": {
        "properties": {
          "enrollments": {
            "items": {
              "$ref": "#/components/schemas/EnrollmentResponse"
            },
            "type": "array",
            "title": "Enrollments"
          },
          "total": {
            "type": "integer",
            "title": "Total"
          }
        },
        "type": "object",
        "required": [
          "enrollments",
          "total"
        ],
        "title": "EnrollmentListResponse"
      },
      "EnrollmentResponse": {
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "title": "Id"
          },
          "tenant_id": {
            "type": "string",
            "format": "uuid",
            "title": "Tenant Id"
          },
          "sequence_id": {
            "type": "string",
            "format": "uuid",
            "title": "Sequence Id"
          },
          "contact_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Contact Id"
          },
          "contact_phone": {
            "type": "string",
            "title": "Contact Phone"
          },
          "contact_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Contact Name"
          },
          "contact_email": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Contact Email"
          },
          "current_step": {
            "type": "integer",
            "title": "Current Step"
          },
          "status": {
            "type": "string",
            "title": "Status"
          },
          "paused_reason": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Paused Reason"
          },
          "next_action_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Next Action At"
          },
          "timezone": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Timezone"
          },
          "total_calls": {
            "type": "integer",
            "title": "Total Calls"
          },
          "total_texts": {
            "type": "integer",
            "title": "Total Texts"
          },
          "total_attempts": {
            "type": "integer",
            "title": "Total Attempts"
          },
          "last_call_outcome": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Last Call Outcome"
          },
          "replied_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Replied At"
          },
          "enrolled_via": {
            "type": "string",
            "title": "Enrolled Via"
          },
          "enrolled_at": {
            "type": "string",
            "format": "date-time",
            "title": "Enrolled At"
          },
          "completed_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Completed At"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "title": "Created At"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "title": "Updated At"
          }
        },
        "type": "object",
        "required": [
          "id",
          "tenant_id",
          "sequence_id",
          "contact_phone",
          "current_step",
          "status",
          "total_calls",
          "total_texts",
          "total_attempts",
          "enrolled_via",
          "enrolled_at",
          "created_at",
          "updated_at"
        ],
        "title": "EnrollmentResponse"
      },
      "EnrollmentStepEntry": {
        "properties": {
          "id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Id"
          },
          "step_index": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Step Index"
          },
          "step_type": {
            "type": "string",
            "title": "Step Type"
          },
          "status": {
            "type": "string",
            "title": "Status"
          },
          "label": {
            "type": "string",
            "title": "Label"
          },
          "detail": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Detail"
          },
          "created_at": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Created At"
          },
          "outcome": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Outcome"
          }
        },
        "type": "object",
        "required": [
          "step_type",
          "status",
          "label"
        ],
        "title": "EnrollmentStepEntry",
        "description": "One row on an enrollment's step timeline (DAN-167 S-19, L-21)."
      },
      "FAQPairCreate": {
        "properties": {
          "question": {
            "type": "string",
            "minLength": 1,
            "title": "Question"
          },
          "answer": {
            "type": "string",
            "minLength": 1,
            "title": "Answer"
          }
        },
        "type": "object",
        "required": [
          "question",
          "answer"
        ],
        "title": "FAQPairCreate",
        "description": "A single FAQ pair for creation."
      },
      "FAQPairResponse": {
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "title": "Id"
          },
          "source_id": {
            "type": "string",
            "format": "uuid",
            "title": "Source Id"
          },
          "question": {
            "type": "string",
            "title": "Question"
          },
          "answer": {
            "type": "string",
            "title": "Answer"
          },
          "sort_order": {
            "type": "integer",
            "title": "Sort Order",
            "default": 0
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "title": "Created At"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "title": "Updated At"
          }
        },
        "type": "object",
        "required": [
          "id",
          "source_id",
          "question",
          "answer",
          "created_at",
          "updated_at"
        ],
        "title": "FAQPairResponse",
        "description": "FAQ pair response."
      },
      "FAQPairUpdate": {
        "properties": {
          "question": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Question"
          },
          "answer": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Answer"
          },
          "sort_order": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Sort Order"
          }
        },
        "type": "object",
        "title": "FAQPairUpdate",
        "description": "Update a single FAQ pair."
      },
      "FAQSourceCreate": {
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 200,
            "minLength": 1,
            "title": "Name"
          },
          "pairs": {
            "items": {
              "$ref": "#/components/schemas/FAQPairCreate"
            },
            "type": "array",
            "title": "Pairs"
          }
        },
        "type": "object",
        "required": [
          "name"
        ],
        "title": "FAQSourceCreate",
        "description": "Request body for creating an FAQ source."
      },
      "FAQSourceResponse": {
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "title": "Id"
          },
          "collection_id": {
            "type": "string",
            "format": "uuid",
            "title": "Collection Id"
          },
          "name": {
            "type": "string",
            "title": "Name"
          },
          "source_type": {
            "type": "string",
            "title": "Source Type",
            "default": "faq"
          },
          "pairs": {
            "items": {
              "$ref": "#/components/schemas/FAQPairResponse"
            },
            "type": "array",
            "title": "Pairs"
          },
          "document_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "title": "Document Id"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "title": "Created At"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "title": "Updated At"
          }
        },
        "type": "object",
        "required": [
          "id",
          "collection_id",
          "name",
          "created_at",
          "updated_at"
        ],
        "title": "FAQSourceResponse",
        "description": "FAQ source response with pairs."
      },
      "FollowUpActivityResponse": {
        "properties": {
          "jobs": {
            "items": {
              "$ref": "#/components/schemas/FollowUpJobResponse"
            },
            "type": "array",
            "title": "Jobs"
          },
          "total": {
            "type": "integer",
            "title": "Total"
          },
          "pending_count": {
            "type": "integer",
            "title": "Pending Count"
          },
          "completed_count": {
            "type": "integer",
            "title": "Completed Count"
          },
          "stopped_count": {
            "type": "integer",
            "title": "Stopped Count"
          },
          "failed_count": {
            "type": "integer",
            "title": "Failed Count"
          }
        },
        "type": "object",
        "required": [
          "jobs",
          "total",
          "pending_count",
          "completed_count",
          "stopped_count",
          "failed_count"
        ],
        "title": "FollowUpActivityResponse"
      },
      "FollowUpJobResponse": {
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "title": "Id"
          },
          "tenant_id": {
            "type": "string",
            "format": "uuid",
            "title": "Tenant Id"
          },
          "text_conversation_id": {
            "type": "string",
            "format": "uuid",
            "title": "Text Conversation Id"
          },
          "text_assistant_id": {
            "type": "string",
            "format": "uuid",
            "title": "Text Assistant Id"
          },
          "ghl_conversation_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Ghl Conversation Id"
          },
          "ghl_contact_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Ghl Contact Id"
          },
          "ghl_location_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Ghl Location Id"
          },
          "provider": {
            "type": "string",
            "title": "Provider",
            "default": "ghl"
          },
          "phone_number_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "title": "Phone Number Id"
          },
          "scenario": {
            "type": "string",
            "title": "Scenario"
          },
          "step_number": {
            "type": "integer",
            "title": "Step Number"
          },
          "channel": {
            "type": "string",
            "title": "Channel"
          },
          "fallback_channel": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Fallback Channel"
          },
          "scheduled_for": {
            "type": "string",
            "format": "date-time",
            "title": "Scheduled For"
          },
          "status": {
            "type": "string",
            "title": "Status"
          },
          "stop_reason": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Stop Reason"
          },
          "generated_message": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Generated Message"
          },
          "message_context": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Message Context"
          },
          "webhook_url": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Webhook Url"
          },
          "attempts": {
            "type": "integer",
            "title": "Attempts"
          },
          "last_error": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Last Error"
          },
          "executed_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Executed At"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "title": "Created At"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "title": "Updated At"
          }
        },
        "type": "object",
        "required": [
          "id",
          "tenant_id",
          "text_conversation_id",
          "text_assistant_id",
          "scenario",
          "step_number",
          "channel",
          "fallback_channel",
          "scheduled_for",
          "status",
          "stop_reason",
          "generated_message",
          "message_context",
          "webhook_url",
          "attempts",
          "last_error",
          "executed_at",
          "created_at",
          "updated_at"
        ],
        "title": "FollowUpJobResponse"
      },
      "ForgotPasswordRequest": {
        "properties": {
          "email": {
            "type": "string",
            "format": "email",
            "title": "Email"
          }
        },
        "type": "object",
        "required": [
          "email"
        ],
        "title": "ForgotPasswordRequest",
        "description": "Request body for forgot password (sends reset email)."
      },
      "FunctionCallEntry": {
        "properties": {
          "function": {
            "type": "string",
            "title": "Function"
          },
          "arguments": {
            "anyOf": [
              {
                "additionalProperties": true,
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Arguments"
          },
          "result": {
            "anyOf": [
              {
                "additionalProperties": true,
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Result"
          },
          "success": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Success"
          },
          "timestamp": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Timestamp"
          }
        },
        "type": "object",
        "required": [
          "function"
        ],
        "title": "FunctionCallEntry",
        "description": "A single function call executed during an AI message."
      },
      "FunctionCallLog": {
        "properties": {
          "function": {
            "type": "string",
            "title": "Function",
            "description": "Function name that was called"
          },
          "arguments": {
            "additionalProperties": true,
            "type": "object",
            "title": "Arguments",
            "description": "Arguments passed to the function"
          },
          "result": {
            "title": "Result",
            "description": "Result returned from the function"
          },
          "success": {
            "type": "boolean",
            "title": "Success",
            "description": "Whether the function call succeeded"
          },
          "timestamp": {
            "type": "string",
            "title": "Timestamp",
            "description": "ISO timestamp of when the call was made"
          }
        },
        "type": "object",
        "required": [
          "function",
          "arguments",
          "result",
          "success",
          "timestamp"
        ],
        "title": "FunctionCallLog",
        "description": "A single function call log entry."
      },
      "FunctionForUpdate": {
        "properties": {
          "name": {
            "type": "string",
            "title": "Name"
          },
          "description": {
            "type": "string",
            "title": "Description"
          },
          "parameters": {
            "additionalProperties": true,
            "type": "object",
            "title": "Parameters"
          }
        },
        "type": "object",
        "required": [
          "name",
          "description"
        ],
        "title": "FunctionForUpdate",
        "description": "A custom function to integrate into the prompt."
      },
      "FunctionLibraryResponse": {
        "properties": {
          "functions": {
            "items": {
              "$ref": "#/components/schemas/FunctionWithAgentsResponse"
            },
            "type": "array",
            "title": "Functions"
          },
          "total": {
            "type": "integer",
            "title": "Total"
          }
        },
        "type": "object",
        "required": [
          "functions",
          "total"
        ],
        "title": "FunctionLibraryResponse",
        "description": "Response schema for the functions library (tenant-level)."
      },
      "FunctionSuggestion": {
        "properties": {
          "tool_name": {
            "type": "string",
            "title": "Tool Name"
          },
          "reason": {
            "type": "string",
            "title": "Reason"
          }
        },
        "type": "object",
        "required": [
          "tool_name",
          "reason"
        ],
        "title": "FunctionSuggestion",
        "description": "A single tool suggestion with reason."
      },
      "FunctionTestRequest": {
        "properties": {
          "arguments": {
            "additionalProperties": true,
            "type": "object",
            "title": "Arguments",
            "description": "Arguments to pass to the function"
          },
          "contact_id": {
            "type": "string",
            "title": "Contact Id",
            "description": "GHL contact ID \u2014 always present via Contact Intelligence",
            "default": "test-contact-id"
          }
        },
        "type": "object",
        "title": "FunctionTestRequest",
        "description": "Request body for testing a custom function's webhook."
      },
      "FunctionTestResponse": {
        "properties": {
          "success": {
            "type": "boolean",
            "title": "Success"
          },
          "status_code": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Status Code"
          },
          "response_time_ms": {
            "type": "number",
            "title": "Response Time Ms"
          },
          "response_body": {
            "anyOf": [
              {},
              {
                "type": "null"
              }
            ],
            "title": "Response Body"
          },
          "error": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Error"
          },
          "signature": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Signature",
            "description": "HMAC signature that was sent (for verification)"
          }
        },
        "type": "object",
        "required": [
          "success",
          "response_time_ms"
        ],
        "title": "FunctionTestResponse",
        "description": "Response schema for function test result."
      },
      "FunctionWithAgentsResponse": {
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "title": "Id"
          },
          "tenant_id": {
            "type": "string",
            "format": "uuid",
            "title": "Tenant Id"
          },
          "name": {
            "type": "string",
            "title": "Name"
          },
          "description": {
            "type": "string",
            "title": "Description"
          },
          "parameters": {
            "additionalProperties": true,
            "type": "object",
            "title": "Parameters"
          },
          "webhook_url": {
            "type": "string",
            "title": "Webhook Url"
          },
          "webhook_method": {
            "type": "string",
            "title": "Webhook Method"
          },
          "webhook_headers": {
            "additionalProperties": {
              "type": "string"
            },
            "type": "object",
            "title": "Webhook Headers"
          },
          "webhook_timeout_ms": {
            "type": "integer",
            "title": "Webhook Timeout Ms"
          },
          "speak_during_execution": {
            "type": "boolean",
            "title": "Speak During Execution"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "title": "Created At"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "title": "Updated At"
          },
          "agent_count": {
            "type": "integer",
            "title": "Agent Count",
            "default": 0
          },
          "agents": {
            "items": {
              "additionalProperties": true,
              "type": "object"
            },
            "type": "array",
            "title": "Agents"
          }
        },
        "type": "object",
        "required": [
          "id",
          "tenant_id",
          "name",
          "description",
          "parameters",
          "webhook_url",
          "webhook_method",
          "webhook_headers",
          "webhook_timeout_ms",
          "speak_during_execution",
          "created_at",
          "updated_at"
        ],
        "title": "FunctionWithAgentsResponse",
        "description": "Response schema for a function with its attached agents."
      },
      "GHLActionPayload": {
        "properties": {
          "data": {
            "additionalProperties": true,
            "type": "object",
            "title": "Data"
          },
          "extras": {
            "additionalProperties": true,
            "type": "object",
            "title": "Extras"
          },
          "meta": {
            "additionalProperties": true,
            "type": "object",
            "title": "Meta"
          }
        },
        "additionalProperties": true,
        "type": "object",
        "title": "GHLActionPayload",
        "description": "Envelope GHL POSTs on action execution.\n\nTwo shapes exist (both observed 2026-07-23):\n- Documented executions: {\"data\": {...fields}, \"extras\": {locationId, ...},\n  \"meta\": {key, version}}\n- Portal \"Test your request\" harness: field values FLAT at the root, no\n  envelope, no locationId in the body (extra=\"allow\" captures them)."
      },
      "GHLApiKeyRequest": {
        "properties": {
          "api_key": {
            "type": "string",
            "minLength": 20,
            "title": "Api Key",
            "description": "GHL Private Integration API key"
          },
          "location_id": {
            "type": "string",
            "minLength": 1,
            "title": "Location Id",
            "description": "GHL Location ID"
          }
        },
        "type": "object",
        "required": [
          "api_key",
          "location_id"
        ],
        "title": "GHLApiKeyRequest",
        "description": "Request schema for connecting GHL with a Private Integration API key."
      },
      "GHLIntegrationInfo": {
        "properties": {
          "id": {
            "type": "string",
            "title": "Id"
          },
          "location_id": {
            "type": "string",
            "title": "Location Id"
          },
          "location_name": {
            "type": "string",
            "title": "Location Name"
          },
          "auth_type": {
            "type": "string",
            "title": "Auth Type",
            "default": "oauth"
          }
        },
        "type": "object",
        "required": [
          "id",
          "location_id",
          "location_name"
        ],
        "title": "GHLIntegrationInfo",
        "description": "Information about a GoHighLevel integration for multi-account selection."
      },
      "GenerateAllKnowledgeResponse": {
        "properties": {
          "services": {
            "type": "string",
            "title": "Services"
          },
          "pricing": {
            "type": "string",
            "title": "Pricing"
          },
          "team": {
            "type": "string",
            "title": "Team"
          },
          "faqs": {
            "type": "string",
            "title": "Faqs"
          }
        },
        "type": "object",
        "required": [
          "services",
          "pricing",
          "team",
          "faqs"
        ],
        "title": "GenerateAllKnowledgeResponse",
        "description": "Response with all generated knowledge sections."
      },
      "GenerateExpressiveRequest": {
        "properties": {
          "current_prompt": {
            "type": "string",
            "maxLength": 50000,
            "minLength": 10,
            "title": "Current Prompt",
            "description": "The existing system prompt for context"
          },
          "preset": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Preset",
            "description": "Preset style: empathetic_support, high_energy_sales, professional_service, friendly_fun"
          },
          "custom_description": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 500
              },
              {
                "type": "null"
              }
            ],
            "title": "Custom Description",
            "description": "Free-text description of desired emotional delivery"
          },
          "refinement": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 500
              },
              {
                "type": "null"
              }
            ],
            "title": "Refinement",
            "description": "Refinement instruction for a previous result"
          },
          "previous_result": {
            "anyOf": [
              {
                "additionalProperties": true,
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Previous Result",
            "description": "Previous AI output to refine"
          }
        },
        "type": "object",
        "required": [
          "current_prompt"
        ],
        "title": "GenerateExpressiveRequest",
        "description": "Request to generate expressive voice configuration."
      },
      "GenerateExpressiveResponse": {
        "properties": {
          "audio_tags": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Audio Tags"
          },
          "emotion_tags": {
            "items": {
              "$ref": "#/components/schemas/EmotionTagItem"
            },
            "type": "array",
            "title": "Emotion Tags"
          },
          "prompt_section": {
            "type": "string",
            "title": "Prompt Section"
          },
          "changes_summary": {
            "type": "string",
            "title": "Changes Summary"
          },
          "updated_prompt": {
            "type": "string",
            "title": "Updated Prompt"
          }
        },
        "type": "object",
        "required": [
          "audio_tags",
          "emotion_tags",
          "prompt_section",
          "changes_summary",
          "updated_prompt"
        ],
        "title": "GenerateExpressiveResponse",
        "description": "Response with generated expressive voice configuration."
      },
      "GenerateFAQRequest": {
        "properties": {
          "content": {
            "type": "string",
            "minLength": 1,
            "title": "Content",
            "description": "Content to extract FAQs from"
          },
          "num_pairs": {
            "type": "integer",
            "maximum": 50.0,
            "minimum": 1.0,
            "title": "Num Pairs",
            "default": 10
          }
        },
        "type": "object",
        "required": [
          "content"
        ],
        "title": "GenerateFAQRequest",
        "description": "Request body for AI-generating FAQ pairs from content."
      },
      "GenerateFunctionSchemaRequest": {
        "properties": {
          "description": {
            "type": "string",
            "maxLength": 500,
            "minLength": 10,
            "title": "Description",
            "description": "Plain English description of what the function should do"
          },
          "webhook_purpose": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 200
              },
              {
                "type": "null"
              }
            ],
            "title": "Webhook Purpose",
            "description": "Optional context about where the webhook sends data"
          }
        },
        "type": "object",
        "required": [
          "description"
        ],
        "title": "GenerateFunctionSchemaRequest",
        "description": "Request to generate a custom function schema using AI."
      },
      "GenerateFunctionSchemaResponse": {
        "properties": {
          "name": {
            "type": "string",
            "title": "Name"
          },
          "description": {
            "type": "string",
            "title": "Description"
          },
          "parameters": {
            "additionalProperties": true,
            "type": "object",
            "title": "Parameters"
          },
          "webhook_method": {
            "type": "string",
            "title": "Webhook Method"
          }
        },
        "type": "object",
        "required": [
          "name",
          "description",
          "parameters",
          "webhook_method"
        ],
        "title": "GenerateFunctionSchemaResponse",
        "description": "Response with AI-generated function schema."
      },
      "GenerateKnowledgeResponse": {
        "properties": {
          "section": {
            "type": "string",
            "title": "Section"
          },
          "suggestion": {
            "type": "string",
            "title": "Suggestion"
          }
        },
        "type": "object",
        "required": [
          "section",
          "suggestion"
        ],
        "title": "GenerateKnowledgeResponse",
        "description": "Response with generated knowledge section."
      },
      "GenerateScenarioRequest": {
        "properties": {
          "description": {
            "type": "string",
            "maxLength": 1000,
            "minLength": 10,
            "title": "Description",
            "description": "Natural language scenario description"
          },
          "model": {
            "type": "string",
            "title": "Model",
            "default": "openai/gpt-5.5"
          }
        },
        "type": "object",
        "required": [
          "description"
        ],
        "title": "GenerateScenarioRequest",
        "description": "Generate a simulation scenario from a natural language description."
      },
      "HTTPValidationError": {
        "properties": {
          "detail": {
            "items": {
              "$ref": "#/components/schemas/ValidationError"
            },
            "type": "array",
            "title": "Detail"
          }
        },
        "type": "object",
        "title": "HTTPValidationError"
      },
      "ImportFromUrlRequest": {
        "properties": {
          "url": {
            "type": "string",
            "maxLength": 500,
            "minLength": 10,
            "title": "Url",
            "description": "Website URL to analyze (e.g., https://example.com)"
          },
          "channel": {
            "type": "string",
            "enum": [
              "phone",
              "sms",
              "web",
              "orb",
              "fb_messenger",
              "ig_messenger",
              "tiktok",
              "whatsapp",
              "fb_lead",
              "ig_lead"
            ],
            "title": "Channel",
            "description": "Demo channel type"
          }
        },
        "type": "object",
        "required": [
          "url",
          "channel"
        ],
        "title": "ImportFromUrlRequest",
        "description": "Request to import demo config from a website URL."
      },
      "ImportGHLNumbersRequest": {
        "properties": {
          "phone_numbers": {
            "items": {
              "additionalProperties": true,
              "type": "object"
            },
            "type": "array",
            "maxItems": 10,
            "minItems": 1,
            "title": "Phone Numbers",
            "description": "List of GHL phone numbers to import"
          }
        },
        "type": "object",
        "required": [
          "phone_numbers"
        ],
        "title": "ImportGHLNumbersRequest",
        "description": "Request to import GoHighLevel phone numbers."
      },
      "ImportNumbersRequest": {
        "properties": {
          "phone_number_sids": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "maxItems": 10,
            "minItems": 1,
            "title": "Phone Number Sids",
            "description": "List of Twilio phone number SIDs to import"
          },
          "configure_sip": {
            "type": "boolean",
            "title": "Configure Sip",
            "description": "DEPRECATED - No longer used (kept for API compatibility)",
            "default": true
          }
        },
        "type": "object",
        "required": [
          "phone_number_sids"
        ],
        "title": "ImportNumbersRequest",
        "description": "Request to import one or more phone numbers."
      },
      "ImportWebsiteRequest": {
        "properties": {
          "url": {
            "type": "string",
            "maxLength": 500,
            "minLength": 5,
            "title": "Url",
            "description": "Website URL to scrape (e.g., https://example.com)"
          }
        },
        "type": "object",
        "required": [
          "url"
        ],
        "title": "ImportWebsiteRequest",
        "description": "Request to import business info from a website."
      },
      "ImportWebsiteResponse": {
        "properties": {
          "business_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Business Name"
          },
          "industry": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Industry"
          },
          "description": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Description"
          },
          "services": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Services"
          },
          "pricing": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Pricing"
          },
          "team": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Team"
          },
          "faqs": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Faqs"
          },
          "urls_scraped": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Urls Scraped"
          },
          "partial_success": {
            "type": "boolean",
            "title": "Partial Success",
            "default": false
          },
          "warnings": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Warnings"
          }
        },
        "type": "object",
        "title": "ImportWebsiteResponse",
        "description": "Response with extracted business information."
      },
      "IndustryPresetsResponse": {
        "properties": {
          "industries": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Industries"
          },
          "presets": {
            "additionalProperties": true,
            "type": "object",
            "title": "Presets"
          }
        },
        "type": "object",
        "required": [
          "industries",
          "presets"
        ],
        "title": "IndustryPresetsResponse",
        "description": "Response with available industry presets."
      },
      "IntegrationInfo": {
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "title": "Id"
          },
          "provider": {
            "type": "string",
            "title": "Provider"
          },
          "provider_account_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Provider Account Id"
          },
          "account_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Account Name"
          },
          "location_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Location Name"
          },
          "is_active": {
            "type": "boolean",
            "title": "Is Active"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "title": "Created At"
          }
        },
        "type": "object",
        "required": [
          "id",
          "provider",
          "is_active",
          "created_at"
        ],
        "title": "IntegrationInfo",
        "description": "Integration info for assignment."
      },
      "IntegrationStatus": {
        "properties": {
          "id": {
            "type": "string",
            "title": "Id"
          },
          "provider": {
            "type": "string",
            "title": "Provider"
          },
          "is_connected": {
            "type": "boolean",
            "title": "Is Connected"
          },
          "is_active": {
            "type": "boolean",
            "title": "Is Active"
          },
          "account_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Account Name"
          },
          "account_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Account Id"
          },
          "expires_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Expires At"
          },
          "calendars": {
            "items": {
              "$ref": "#/components/schemas/CalendarInfo"
            },
            "type": "array",
            "title": "Calendars",
            "default": []
          }
        },
        "type": "object",
        "required": [
          "id",
          "provider",
          "is_connected",
          "is_active"
        ],
        "title": "IntegrationStatus",
        "description": "Status of an integration."
      },
      "InvoiceItem": {
        "properties": {
          "id": {
            "type": "string",
            "title": "Id"
          },
          "amount_due": {
            "type": "integer",
            "title": "Amount Due"
          },
          "amount_paid": {
            "type": "integer",
            "title": "Amount Paid"
          },
          "status": {
            "type": "string",
            "title": "Status"
          },
          "period_start": {
            "type": "string",
            "format": "date-time",
            "title": "Period Start"
          },
          "period_end": {
            "type": "string",
            "format": "date-time",
            "title": "Period End"
          },
          "invoice_pdf": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Invoice Pdf"
          },
          "hosted_invoice_url": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Hosted Invoice Url"
          },
          "created": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Created"
          }
        },
        "type": "object",
        "required": [
          "id",
          "amount_due",
          "amount_paid",
          "status",
          "period_start",
          "period_end"
        ],
        "title": "InvoiceItem",
        "description": "Stripe invoice item."
      },
      "InvoiceListResponse": {
        "properties": {
          "invoices": {
            "items": {
              "$ref": "#/components/schemas/InvoiceItem"
            },
            "type": "array",
            "title": "Invoices"
          }
        },
        "type": "object",
        "required": [
          "invoices"
        ],
        "title": "InvoiceListResponse",
        "description": "Response containing list of invoices."
      },
      "InvoiceSubAccountLine": {
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "title": "Id"
          },
          "name": {
            "type": "string",
            "title": "Name"
          },
          "voice_minutes": {
            "type": "number",
            "title": "Voice Minutes"
          },
          "voice_calls": {
            "type": "integer",
            "title": "Voice Calls"
          },
          "voice_revenue_cents": {
            "type": "integer",
            "title": "Voice Revenue Cents"
          },
          "text_count": {
            "type": "integer",
            "title": "Text Count"
          },
          "text_revenue_cents": {
            "type": "integer",
            "title": "Text Revenue Cents"
          },
          "platform_fee_cents": {
            "type": "integer",
            "title": "Platform Fee Cents"
          },
          "total_due_cents": {
            "type": "integer",
            "title": "Total Due Cents"
          }
        },
        "type": "object",
        "required": [
          "id",
          "name",
          "voice_minutes",
          "voice_calls",
          "voice_revenue_cents",
          "text_count",
          "text_revenue_cents",
          "platform_fee_cents",
          "total_due_cents"
        ],
        "title": "InvoiceSubAccountLine",
        "description": "Per-sub-account billing line item for invoice summary."
      },
      "InvoiceSummaryResponse": {
        "properties": {
          "period_start": {
            "type": "string",
            "format": "date-time",
            "title": "Period Start"
          },
          "period_end": {
            "type": "string",
            "format": "date-time",
            "title": "Period End"
          },
          "period_source": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Period Source"
          },
          "sub_accounts": {
            "items": {
              "$ref": "#/components/schemas/InvoiceSubAccountLine"
            },
            "type": "array",
            "title": "Sub Accounts"
          },
          "grand_total_cents": {
            "type": "integer",
            "title": "Grand Total Cents"
          },
          "grand_voice_revenue_cents": {
            "type": "integer",
            "title": "Grand Voice Revenue Cents"
          },
          "grand_text_revenue_cents": {
            "type": "integer",
            "title": "Grand Text Revenue Cents"
          },
          "grand_platform_fees_cents": {
            "type": "integer",
            "title": "Grand Platform Fees Cents"
          }
        },
        "type": "object",
        "required": [
          "period_start",
          "period_end",
          "sub_accounts",
          "grand_total_cents",
          "grand_voice_revenue_cents",
          "grand_text_revenue_cents",
          "grand_platform_fees_cents"
        ],
        "title": "InvoiceSummaryResponse",
        "description": "Aggregated invoice summary across all sub-accounts for current billing period."
      },
      "KnowledgeBaseCreate": {
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 100,
            "minLength": 1,
            "title": "Name",
            "description": "Name of the Knowledge Base"
          }
        },
        "type": "object",
        "required": [
          "name"
        ],
        "title": "KnowledgeBaseCreate",
        "description": "Request body for creating a Knowledge Base."
      },
      "KnowledgeBaseListResponse": {
        "properties": {
          "knowledge_bases": {
            "items": {
              "$ref": "#/components/schemas/KnowledgeBaseResponse"
            },
            "type": "array",
            "title": "Knowledge Bases"
          },
          "total": {
            "type": "integer",
            "title": "Total"
          }
        },
        "type": "object",
        "required": [
          "knowledge_bases",
          "total"
        ],
        "title": "KnowledgeBaseListResponse",
        "description": "List of Knowledge Bases response."
      },
      "KnowledgeBaseResponse": {
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "title": "Id"
          },
          "tenant_id": {
            "type": "string",
            "format": "uuid",
            "title": "Tenant Id"
          },
          "xai_collection_id": {
            "type": "string",
            "title": "Xai Collection Id"
          },
          "name": {
            "type": "string",
            "title": "Name"
          },
          "document_count": {
            "type": "integer",
            "title": "Document Count",
            "default": 0
          },
          "total_bytes": {
            "type": "integer",
            "title": "Total Bytes",
            "default": 0
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "title": "Created At"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "title": "Updated At"
          }
        },
        "type": "object",
        "required": [
          "id",
          "tenant_id",
          "xai_collection_id",
          "name",
          "created_at",
          "updated_at"
        ],
        "title": "KnowledgeBaseResponse",
        "description": "Knowledge Base data response."
      },
      "KnowledgeBaseUpdate": {
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 100,
            "minLength": 1,
            "title": "Name",
            "description": "New name for the Knowledge Base"
          }
        },
        "type": "object",
        "required": [
          "name"
        ],
        "title": "KnowledgeBaseUpdate",
        "description": "Request body for updating a Knowledge Base."
      },
      "LinkedAgentSummary": {
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "title": "Id"
          },
          "name": {
            "type": "string",
            "title": "Name"
          },
          "tools_enabled": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Tools Enabled",
            "default": []
          }
        },
        "type": "object",
        "required": [
          "id",
          "name"
        ],
        "title": "LinkedAgentSummary",
        "description": "Summary of linked agent for display."
      },
      "LinkedTextAssistantSummary": {
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "title": "Id"
          },
          "is_active": {
            "type": "boolean",
            "title": "Is Active"
          },
          "enabled_channels": {
            "anyOf": [
              {
                "additionalProperties": true,
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Enabled Channels"
          }
        },
        "type": "object",
        "required": [
          "id",
          "is_active"
        ],
        "title": "LinkedTextAssistantSummary",
        "description": "Minimal text assistant info returned with agent responses."
      },
      "LoginRequest": {
        "properties": {
          "email": {
            "type": "string",
            "format": "email",
            "title": "Email"
          },
          "password": {
            "type": "string",
            "title": "Password"
          }
        },
        "type": "object",
        "required": [
          "email",
          "password"
        ],
        "title": "LoginRequest",
        "description": "Request body for user login."
      },
      "LogoUploadResponse": {
        "properties": {
          "logo_url": {
            "type": "string",
            "title": "Logo Url"
          },
          "file_size": {
            "type": "integer",
            "title": "File Size"
          }
        },
        "type": "object",
        "required": [
          "logo_url",
          "file_size"
        ],
        "title": "LogoUploadResponse",
        "description": "Response after uploading logo."
      },
      "MCPServerConfig": {
        "properties": {
          "server_url": {
            "type": "string",
            "maxLength": 2048,
            "title": "Server Url"
          },
          "server_label": {
            "type": "string",
            "maxLength": 64,
            "title": "Server Label"
          },
          "server_description": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 512
              },
              {
                "type": "null"
              }
            ],
            "title": "Server Description"
          },
          "bearer_token": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 2048
              },
              {
                "type": "null"
              }
            ],
            "title": "Bearer Token"
          },
          "allowed_tools": {
            "anyOf": [
              {
                "items": {
                  "type": "string"
                },
                "type": "array",
                "maxItems": 50
              },
              {
                "type": "null"
              }
            ],
            "title": "Allowed Tools"
          },
          "enabled": {
            "type": "boolean",
            "title": "Enabled",
            "default": true
          }
        },
        "type": "object",
        "required": [
          "server_url",
          "server_label"
        ],
        "title": "MCPServerConfig",
        "description": "Per-agent MCP server. Used for create/update payloads.\n\nBearer token semantics for PATCH (mirrored exactly in\n`_upsert_mcp_servers_for_agent`):\n  - field absent / None  -> preserve existing ciphertext\n  - empty string \"\"      -> explicit clear (revoke stored bearer)\n  - non-empty plaintext  -> replace (encrypt new value)"
      },
      "MCPServerSummary": {
        "properties": {
          "id": {
            "type": "string",
            "title": "Id"
          },
          "server_url": {
            "type": "string",
            "title": "Server Url"
          },
          "server_label": {
            "type": "string",
            "title": "Server Label"
          },
          "server_description": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Server Description"
          },
          "auth_configured": {
            "type": "boolean",
            "title": "Auth Configured"
          },
          "allowed_tools": {
            "anyOf": [
              {
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Allowed Tools"
          },
          "enabled": {
            "type": "boolean",
            "title": "Enabled"
          }
        },
        "type": "object",
        "required": [
          "id",
          "server_url",
          "server_label",
          "auth_configured",
          "enabled"
        ],
        "title": "MCPServerSummary",
        "description": "Read model: never includes ciphertext or plaintext bearer."
      },
      "MSImportRequest": {
        "properties": {
          "messaging_service_sid": {
            "type": "string",
            "title": "Messaging Service Sid"
          },
          "integration_id": {
            "type": "string",
            "format": "uuid",
            "title": "Integration Id"
          },
          "name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Name"
          }
        },
        "type": "object",
        "required": [
          "messaging_service_sid",
          "integration_id"
        ],
        "title": "MSImportRequest",
        "description": "Body for POST /sms-pools/ \u2014 import an existing Twilio MS as a pool."
      },
      "MSListItem": {
        "properties": {
          "sid": {
            "type": "string",
            "title": "Sid"
          },
          "friendly_name": {
            "type": "string",
            "title": "Friendly Name"
          },
          "sticky_sender": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Sticky Sender"
          },
          "area_code_geomatch": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Area Code Geomatch"
          },
          "scaler": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Scaler"
          },
          "inbound_request_url": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Inbound Request Url"
          },
          "integration_id": {
            "type": "string",
            "format": "uuid",
            "title": "Integration Id"
          }
        },
        "type": "object",
        "required": [
          "sid",
          "friendly_name",
          "integration_id"
        ],
        "title": "MSListItem",
        "description": "A Twilio Messaging Service visible to a tenant (across all their integrations)."
      },
      "MeResponse": {
        "properties": {
          "user": {
            "$ref": "#/components/schemas/UserResponse"
          },
          "tenant": {
            "$ref": "#/components/schemas/TenantResponse"
          }
        },
        "type": "object",
        "required": [
          "user",
          "tenant"
        ],
        "title": "MeResponse",
        "description": "Response for /auth/me endpoint."
      },
      "NoteCreateRequest": {
        "properties": {
          "body": {
            "type": "string",
            "title": "Body"
          }
        },
        "type": "object",
        "required": [
          "body"
        ],
        "title": "NoteCreateRequest",
        "description": "Request to create a note on a GHL contact."
      },
      "NoteResponse": {
        "properties": {
          "id": {
            "type": "string",
            "title": "Id"
          },
          "body": {
            "type": "string",
            "title": "Body"
          },
          "created_at": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Created At"
          },
          "created_by": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Created By"
          }
        },
        "type": "object",
        "required": [
          "id",
          "body"
        ],
        "title": "NoteResponse",
        "description": "A single note from GHL."
      },
      "NotesListResponse": {
        "properties": {
          "notes": {
            "items": {
              "$ref": "#/components/schemas/NoteResponse"
            },
            "type": "array",
            "title": "Notes"
          },
          "total": {
            "type": "integer",
            "title": "Total"
          }
        },
        "type": "object",
        "required": [
          "notes",
          "total"
        ],
        "title": "NotesListResponse",
        "description": "List of notes for a contact."
      },
      "NotificationListResponse": {
        "properties": {
          "notifications": {
            "items": {
              "$ref": "#/components/schemas/NotificationResponse"
            },
            "type": "array",
            "title": "Notifications"
          },
          "total": {
            "type": "integer",
            "title": "Total"
          },
          "unread_count": {
            "type": "integer",
            "title": "Unread Count"
          }
        },
        "type": "object",
        "required": [
          "notifications",
          "total",
          "unread_count"
        ],
        "title": "NotificationListResponse",
        "description": "Paginated list of notifications."
      },
      "NotificationResponse": {
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "title": "Id"
          },
          "tenant_id": {
            "type": "string",
            "format": "uuid",
            "title": "Tenant Id"
          },
          "type": {
            "type": "string",
            "title": "Type"
          },
          "title": {
            "type": "string",
            "title": "Title"
          },
          "body": {
            "type": "string",
            "title": "Body"
          },
          "metadata": {
            "additionalProperties": true,
            "type": "object",
            "title": "Metadata",
            "default": {}
          },
          "is_read": {
            "type": "boolean",
            "title": "Is Read"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "title": "Created At"
          },
          "source_account_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Source Account Name"
          }
        },
        "type": "object",
        "required": [
          "id",
          "tenant_id",
          "type",
          "title",
          "body",
          "is_read",
          "created_at"
        ],
        "title": "NotificationResponse",
        "description": "Single in-app notification."
      },
      "NotificationSettingsResponse": {
        "properties": {
          "email_new_call": {
            "type": "boolean",
            "title": "Email New Call",
            "default": true
          },
          "email_call_summary": {
            "type": "boolean",
            "title": "Email Call Summary",
            "default": true
          },
          "email_weekly_digest": {
            "type": "boolean",
            "title": "Email Weekly Digest",
            "default": false
          },
          "additional_emails": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Additional Emails"
          },
          "call_notification_mode": {
            "type": "string",
            "enum": [
              "every_call",
              "daily",
              "off"
            ],
            "title": "Call Notification Mode",
            "default": "every_call"
          },
          "quiet_hours_enabled": {
            "type": "boolean",
            "title": "Quiet Hours Enabled",
            "default": false
          },
          "quiet_hours_start": {
            "type": "string",
            "format": "time",
            "title": "Quiet Hours Start",
            "default": "22:00:00"
          },
          "quiet_hours_end": {
            "type": "string",
            "format": "time",
            "title": "Quiet Hours End",
            "default": "07:00:00"
          },
          "quiet_hours_timezone": {
            "type": "string",
            "title": "Quiet Hours Timezone",
            "default": "America/New_York"
          },
          "notification_frequency": {
            "type": "string",
            "enum": [
              "immediate",
              "daily",
              "weekly"
            ],
            "title": "Notification Frequency",
            "default": "immediate"
          },
          "sms_enabled": {
            "type": "boolean",
            "title": "Sms Enabled",
            "default": false
          },
          "id": {
            "type": "string",
            "format": "uuid",
            "title": "Id"
          },
          "tenant_id": {
            "type": "string",
            "format": "uuid",
            "title": "Tenant Id"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "title": "Created At"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "title": "Updated At"
          }
        },
        "type": "object",
        "required": [
          "id",
          "tenant_id",
          "created_at",
          "updated_at"
        ],
        "title": "NotificationSettingsResponse",
        "description": "Notification settings response with metadata."
      },
      "NotificationSettingsUpdate": {
        "properties": {
          "email_new_call": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Email New Call"
          },
          "email_call_summary": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Email Call Summary"
          },
          "email_weekly_digest": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Email Weekly Digest"
          },
          "additional_emails": {
            "anyOf": [
              {
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Additional Emails"
          },
          "call_notification_mode": {
            "anyOf": [
              {
                "type": "string",
                "enum": [
                  "every_call",
                  "daily",
                  "off"
                ]
              },
              {
                "type": "null"
              }
            ],
            "title": "Call Notification Mode"
          },
          "quiet_hours_enabled": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Quiet Hours Enabled"
          },
          "quiet_hours_start": {
            "anyOf": [
              {
                "type": "string",
                "format": "time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Quiet Hours Start"
          },
          "quiet_hours_end": {
            "anyOf": [
              {
                "type": "string",
                "format": "time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Quiet Hours End"
          },
          "quiet_hours_timezone": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Quiet Hours Timezone"
          },
          "notification_frequency": {
            "anyOf": [
              {
                "type": "string",
                "enum": [
                  "immediate",
                  "daily",
                  "weekly"
                ]
              },
              {
                "type": "null"
              }
            ],
            "title": "Notification Frequency"
          },
          "sms_enabled": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Sms Enabled"
          }
        },
        "type": "object",
        "title": "NotificationSettingsUpdate",
        "description": "Request body for updating notification settings."
      },
      "OffersResponse": {
        "properties": {
          "jumpstart": {
            "type": "boolean",
            "title": "Jumpstart"
          },
          "bundle": {
            "type": "boolean",
            "title": "Bundle"
          }
        },
        "type": "object",
        "required": [
          "jumpstart",
          "bundle"
        ],
        "title": "OffersResponse",
        "description": "DAN-350: course offers the server will honour at checkout right now."
      },
      "OnboardingProgress": {
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "title": "Id"
          },
          "tenant_id": {
            "type": "string",
            "format": "uuid",
            "title": "Tenant Id"
          },
          "current_step": {
            "type": "integer",
            "title": "Current Step",
            "default": 1
          },
          "completed_steps": {
            "items": {
              "type": "integer"
            },
            "type": "array",
            "title": "Completed Steps",
            "default": []
          },
          "account_type": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Account Type"
          },
          "business_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Business Name"
          },
          "industry": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Industry"
          },
          "ghl_connected": {
            "type": "boolean",
            "title": "Ghl Connected",
            "default": false
          },
          "ghl_integration_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Ghl Integration Id"
          },
          "phone_number_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Phone Number Id"
          },
          "sub_account_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Sub Account Id"
          },
          "agent_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Agent Id"
          },
          "deployed": {
            "type": "boolean",
            "title": "Deployed",
            "default": false
          },
          "calendar_connected": {
            "type": "boolean",
            "title": "Calendar Connected",
            "default": false
          },
          "phone_purchased": {
            "type": "boolean",
            "title": "Phone Purchased",
            "default": false
          },
          "agent_created": {
            "type": "boolean",
            "title": "Agent Created",
            "default": false
          },
          "test_call_completed": {
            "type": "boolean",
            "title": "Test Call Completed",
            "default": false
          },
          "completed_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Completed At"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "title": "Created At"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "title": "Updated At"
          }
        },
        "type": "object",
        "required": [
          "id",
          "tenant_id",
          "created_at",
          "updated_at"
        ],
        "title": "OnboardingProgress",
        "description": "Onboarding progress response model."
      },
      "OpenInvoiceResponse": {
        "properties": {
          "amount_due": {
            "type": "integer",
            "title": "Amount Due"
          },
          "amount_due_formatted": {
            "type": "string",
            "title": "Amount Due Formatted"
          },
          "currency": {
            "type": "string",
            "title": "Currency"
          },
          "hosted_invoice_url": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Hosted Invoice Url"
          },
          "status": {
            "type": "string",
            "title": "Status"
          }
        },
        "type": "object",
        "required": [
          "amount_due",
          "amount_due_formatted",
          "currency",
          "status"
        ],
        "title": "OpenInvoiceResponse",
        "description": "The current open (unpaid) invoice + hosted pay-page URL for the overlay."
      },
      "OperatingHours": {
        "properties": {
          "start": {
            "type": "string",
            "pattern": "^\\d{2}:\\d{2}$",
            "title": "Start",
            "description": "Start time in HH:MM 24h format",
            "default": "09:00"
          },
          "end": {
            "type": "string",
            "pattern": "^\\d{2}:\\d{2}$",
            "title": "End",
            "description": "End time in HH:MM 24h format",
            "default": "17:00"
          },
          "days": {
            "items": {
              "type": "integer"
            },
            "type": "array",
            "title": "Days",
            "description": "ISO weekdays (1=Mon..7=Sun)",
            "default": [
              1,
              2,
              3,
              4,
              5
            ]
          },
          "timezone": {
            "type": "string",
            "title": "Timezone",
            "description": "IANA timezone for the operating hours",
            "default": "America/New_York"
          }
        },
        "type": "object",
        "title": "OperatingHours",
        "description": "Business hours constraint for when the sequence can execute steps."
      },
      "OutboundCallRequest": {
        "properties": {
          "to_number": {
            "type": "string",
            "pattern": "^\\+(?:1[2-9]\\d{9}|[2-9]\\d{6,14})$",
            "title": "To Number",
            "description": "Recipient phone number in E.164 format (e.g., +14155551234)"
          },
          "from_phone_number_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "title": "From Phone Number Id",
            "description": "Specific phone number to call from. If not provided, uses agent's primary number."
          },
          "ghl_contact_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Ghl Contact Id",
            "description": "GHL contact ID for pre-flight conversation checks"
          }
        },
        "type": "object",
        "required": [
          "to_number"
        ],
        "title": "OutboundCallRequest",
        "description": "Request to initiate an outbound call."
      },
      "OutboundCallResponse": {
        "properties": {
          "call_id": {
            "type": "string",
            "format": "uuid",
            "title": "Call Id",
            "description": "Internal call log ID"
          },
          "call_sid": {
            "type": "string",
            "title": "Call Sid",
            "description": "Twilio call SID"
          },
          "status": {
            "type": "string",
            "title": "Status",
            "description": "Initial call status"
          },
          "from_number": {
            "type": "string",
            "title": "From Number",
            "description": "Calling from number"
          },
          "to_number": {
            "type": "string",
            "title": "To Number",
            "description": "Calling to number"
          },
          "agent_id": {
            "type": "string",
            "format": "uuid",
            "title": "Agent Id",
            "description": "Agent handling the call"
          },
          "initiated_at": {
            "type": "string",
            "format": "date-time",
            "title": "Initiated At",
            "description": "When call was initiated"
          }
        },
        "type": "object",
        "required": [
          "call_id",
          "call_sid",
          "status",
          "from_number",
          "to_number",
          "agent_id",
          "initiated_at"
        ],
        "title": "OutboundCallResponse",
        "description": "Response after initiating an outbound call."
      },
      "OutboundComplianceStatus": {
        "properties": {
          "outbound_enabled": {
            "type": "boolean",
            "title": "Outbound Enabled"
          },
          "terms_version": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Terms Version"
          },
          "accepted_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Accepted At"
          },
          "accepted_by": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Accepted By"
          }
        },
        "type": "object",
        "required": [
          "outbound_enabled"
        ],
        "title": "OutboundComplianceStatus",
        "description": "Response: current outbound compliance status for a tenant."
      },
      "OutboundTextSendRequest": {
        "properties": {
          "phone_number": {
            "anyOf": [
              {
                "type": "string",
                "pattern": "^\\+[1-9]\\d{1,14}$"
              },
              {
                "type": "null"
              }
            ],
            "title": "Phone Number"
          },
          "ghl_contact_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Ghl Contact Id"
          },
          "message": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 1600
              },
              {
                "type": "null"
              }
            ],
            "title": "Message"
          },
          "ai_generate": {
            "type": "boolean",
            "title": "Ai Generate",
            "default": false
          },
          "ai_context": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Ai Context"
          },
          "channel": {
            "type": "string",
            "title": "Channel",
            "default": "sms"
          }
        },
        "type": "object",
        "title": "OutboundTextSendRequest",
        "description": "Request body for sending an outbound text message."
      },
      "OutboundTextSendResponse": {
        "properties": {
          "success": {
            "type": "boolean",
            "title": "Success"
          },
          "messages_sent": {
            "type": "integer",
            "title": "Messages Sent"
          },
          "messages": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Messages"
          },
          "conversation_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Conversation Id"
          },
          "contact_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Contact Id"
          },
          "channel": {
            "type": "string",
            "title": "Channel"
          }
        },
        "type": "object",
        "required": [
          "success",
          "messages_sent",
          "messages",
          "channel"
        ],
        "title": "OutboundTextSendResponse",
        "description": "Response for outbound text send."
      },
      "PendingSignupRequest": {
        "properties": {
          "email": {
            "type": "string",
            "format": "email",
            "title": "Email"
          },
          "password": {
            "type": "string",
            "minLength": 6,
            "title": "Password",
            "description": "Minimum 6 characters (Supabase requirement)"
          },
          "company_name": {
            "type": "string",
            "maxLength": 255,
            "minLength": 2,
            "title": "Company Name"
          },
          "plan": {
            "type": "string",
            "enum": [
              "payg",
              "starter",
              "agency",
              "pro"
            ],
            "title": "Plan",
            "default": "starter"
          },
          "billing_period": {
            "type": "string",
            "enum": [
              "monthly",
              "annual"
            ],
            "title": "Billing Period",
            "default": "monthly"
          },
          "tos_accepted": {
            "type": "boolean",
            "title": "Tos Accepted",
            "description": "User must accept Terms of Service and Privacy Policy",
            "default": false
          },
          "utm_source": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Utm Source"
          },
          "utm_medium": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Utm Medium"
          },
          "utm_campaign": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Utm Campaign"
          },
          "utm_content": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Utm Content"
          },
          "utm_term": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Utm Term"
          },
          "referrer_url": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Referrer Url"
          },
          "offer": {
            "anyOf": [
              {
                "type": "string",
                "const": "jumpstart"
              },
              {
                "type": "null"
              }
            ],
            "title": "Offer"
          },
          "bundle": {
            "type": "boolean",
            "title": "Bundle",
            "default": false
          },
          "referral_code": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 64,
                "pattern": "^[A-Za-z0-9_-]{1,64}$"
              },
              {
                "type": "null"
              }
            ],
            "title": "Referral Code",
            "description": "Partner code from the signup link. An invalid code is dropped, never a 422."
          },
          "signup_channel": {
            "type": "string",
            "enum": [
              "web",
              "mcp",
              "kit",
              "api"
            ],
            "title": "Signup Channel",
            "description": "Which door the signup came through. Unknown values become web.",
            "default": "web"
          }
        },
        "type": "object",
        "required": [
          "email",
          "password",
          "company_name"
        ],
        "title": "PendingSignupRequest",
        "description": "Request body for Payment-First signup (account created after payment)."
      },
      "PendingSignupResponse": {
        "properties": {
          "checkout_url": {
            "type": "string",
            "title": "Checkout Url"
          }
        },
        "type": "object",
        "required": [
          "checkout_url"
        ],
        "title": "PendingSignupResponse",
        "description": "Response with Stripe checkout URL for Payment-First signup."
      },
      "PhoneNumberListResponse": {
        "properties": {
          "phone_numbers": {
            "items": {
              "$ref": "#/components/schemas/PhoneNumberResponse"
            },
            "type": "array",
            "title": "Phone Numbers"
          },
          "total": {
            "type": "integer",
            "title": "Total"
          }
        },
        "type": "object",
        "required": [
          "phone_numbers",
          "total"
        ],
        "title": "PhoneNumberListResponse",
        "description": "Response schema for listing phone numbers."
      },
      "PhoneNumberPurchase": {
        "properties": {
          "phone_number": {
            "type": "string",
            "title": "Phone Number",
            "description": "E.164 format: +14155551234"
          }
        },
        "type": "object",
        "required": [
          "phone_number"
        ],
        "title": "PhoneNumberPurchase",
        "description": "Request schema for purchasing a phone number."
      },
      "PhoneNumberResponse": {
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "title": "Id"
          },
          "tenant_id": {
            "type": "string",
            "format": "uuid",
            "title": "Tenant Id"
          },
          "twilio_sid": {
            "type": "string",
            "title": "Twilio Sid"
          },
          "phone_number": {
            "type": "string",
            "title": "Phone Number"
          },
          "friendly_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Friendly Name"
          },
          "agent_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "title": "Agent Id"
          },
          "is_active": {
            "type": "boolean",
            "title": "Is Active",
            "default": true
          },
          "monthly_cost_cents": {
            "type": "integer",
            "title": "Monthly Cost Cents"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "title": "Created At"
          },
          "sub_account_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Sub Account Name"
          },
          "sub_account_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "title": "Sub Account Id"
          },
          "voice_capable": {
            "type": "boolean",
            "title": "Voice Capable",
            "default": true
          },
          "sms_capable": {
            "type": "boolean",
            "title": "Sms Capable",
            "default": false
          },
          "mms_capable": {
            "type": "boolean",
            "title": "Mms Capable",
            "default": false
          },
          "source": {
            "type": "string",
            "title": "Source",
            "default": "twilio"
          },
          "a2p_campaign_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "A2P Campaign Id"
          },
          "a2p_status": {
            "type": "string",
            "title": "A2P Status",
            "default": "unknown"
          },
          "a2p_verified_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "A2P Verified At"
          },
          "a2p_last_checked": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "A2P Last Checked"
          },
          "messaging_enabled": {
            "type": "boolean",
            "title": "Messaging Enabled",
            "default": false
          },
          "a2p_metadata": {
            "anyOf": [
              {
                "additionalProperties": true,
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "A2P Metadata"
          }
        },
        "type": "object",
        "required": [
          "id",
          "tenant_id",
          "twilio_sid",
          "phone_number",
          "monthly_cost_cents",
          "created_at"
        ],
        "title": "PhoneNumberResponse",
        "description": "Response schema for a phone number."
      },
      "PhoneNumberUpdate": {
        "properties": {
          "agent_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "title": "Agent Id",
            "description": "Assign to agent"
          },
          "friendly_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Friendly Name",
            "description": "Display name"
          }
        },
        "type": "object",
        "title": "PhoneNumberUpdate",
        "description": "Request schema for updating a phone number."
      },
      "PoolMemberResponse": {
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "title": "Id"
          },
          "phone_number_id": {
            "type": "string",
            "format": "uuid",
            "title": "Phone Number Id"
          },
          "phone_number": {
            "type": "string",
            "title": "Phone Number"
          },
          "first_used_date": {
            "anyOf": [
              {
                "type": "string",
                "format": "date"
              },
              {
                "type": "null"
              }
            ],
            "title": "First Used Date"
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "quarantined",
              "paused",
              "removed"
            ],
            "title": "Status"
          },
          "quarantined_until": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Quarantined Until"
          },
          "quarantine_reason": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Quarantine Reason"
          },
          "last_used_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Last Used At"
          },
          "today_sent": {
            "type": "integer",
            "title": "Today Sent",
            "default": 0
          },
          "today_cap": {
            "type": "integer",
            "title": "Today Cap",
            "default": 10
          }
        },
        "type": "object",
        "required": [
          "id",
          "phone_number_id",
          "phone_number",
          "status"
        ],
        "title": "PoolMemberResponse",
        "description": "A phone number attached to a pool, with today's usage stats."
      },
      "PoolResponse": {
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "title": "Id"
          },
          "tenant_id": {
            "type": "string",
            "format": "uuid",
            "title": "Tenant Id"
          },
          "sub_account_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "title": "Sub Account Id"
          },
          "integration_id": {
            "type": "string",
            "format": "uuid",
            "title": "Integration Id"
          },
          "name": {
            "type": "string",
            "title": "Name"
          },
          "messaging_service_sid": {
            "type": "string",
            "title": "Messaging Service Sid"
          },
          "warm_up_days": {
            "type": "integer",
            "title": "Warm Up Days"
          },
          "daily_cap_max": {
            "type": "integer",
            "title": "Daily Cap Max"
          },
          "daily_cap_start": {
            "type": "integer",
            "title": "Daily Cap Start"
          },
          "daily_budget": {
            "type": "integer",
            "title": "Daily Budget",
            "default": 25
          },
          "new_pct": {
            "type": "integer",
            "title": "New Pct",
            "default": 60
          },
          "allow_budget_rollover": {
            "type": "boolean",
            "title": "Allow Budget Rollover",
            "default": false
          },
          "budget_reset_timezone": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Budget Reset Timezone"
          },
          "status": {
            "type": "string",
            "title": "Status"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "title": "Created At"
          },
          "members": {
            "items": {
              "$ref": "#/components/schemas/PoolMemberResponse"
            },
            "type": "array",
            "title": "Members"
          },
          "import_warnings": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Import Warnings"
          }
        },
        "type": "object",
        "required": [
          "id",
          "tenant_id",
          "integration_id",
          "name",
          "messaging_service_sid",
          "warm_up_days",
          "daily_cap_max",
          "daily_cap_start",
          "status",
          "created_at"
        ],
        "title": "PoolResponse",
        "description": "A pool row with its members expanded."
      },
      "PoolUpdate": {
        "properties": {
          "daily_budget": {
            "anyOf": [
              {
                "type": "integer",
                "maximum": 1000.0,
                "minimum": 1.0
              },
              {
                "type": "null"
              }
            ],
            "title": "Daily Budget"
          },
          "new_pct": {
            "anyOf": [
              {
                "type": "integer",
                "maximum": 100.0,
                "minimum": 0.0
              },
              {
                "type": "null"
              }
            ],
            "title": "New Pct"
          },
          "allow_budget_rollover": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Allow Budget Rollover"
          },
          "budget_reset_timezone": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Budget Reset Timezone"
          },
          "name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Name"
          }
        },
        "type": "object",
        "title": "PoolUpdate",
        "description": "Body for PATCH /sms-pools/{pool_id} \u2014 pool-default sending config."
      },
      "PortalRequest": {
        "properties": {
          "return_url": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Return Url"
          },
          "flow": {
            "anyOf": [
              {
                "type": "string",
                "const": "cancel"
              },
              {
                "type": "null"
              }
            ],
            "title": "Flow"
          }
        },
        "type": "object",
        "title": "PortalRequest",
        "description": "Request to create a Stripe Customer Portal session."
      },
      "PortalResponse": {
        "properties": {
          "portal_url": {
            "type": "string",
            "title": "Portal Url"
          }
        },
        "type": "object",
        "required": [
          "portal_url"
        ],
        "title": "PortalResponse",
        "description": "Response containing Stripe Portal URL."
      },
      "PreviewGreetingTTSRequest": {
        "properties": {
          "text": {
            "type": "string",
            "maxLength": 500,
            "minLength": 1,
            "title": "Text"
          },
          "voice_provider": {
            "type": "string",
            "pattern": "^(xai|openai|elevenlabs|gemini|openai_live)$",
            "title": "Voice Provider"
          },
          "voice_id": {
            "type": "string",
            "maxLength": 200,
            "minLength": 1,
            "title": "Voice Id"
          }
        },
        "type": "object",
        "required": [
          "text",
          "voice_provider",
          "voice_id"
        ],
        "title": "PreviewGreetingTTSRequest",
        "description": "Request to preview a greeting via TTS."
      },
      "PreviewPromptRequest": {
        "properties": {
          "business_name": {
            "type": "string",
            "maxLength": 200,
            "minLength": 1,
            "title": "Business Name"
          },
          "agent_name": {
            "type": "string",
            "maxLength": 100,
            "minLength": 1,
            "title": "Agent Name",
            "default": "Alex"
          },
          "industry": {
            "type": "string",
            "maxLength": 100,
            "title": "Industry",
            "default": ""
          },
          "personality": {
            "type": "string",
            "maxLength": 50,
            "title": "Personality",
            "default": "friendly"
          },
          "description": {
            "type": "string",
            "maxLength": 10000,
            "title": "Description",
            "default": ""
          },
          "services": {
            "type": "string",
            "maxLength": 10000,
            "title": "Services",
            "default": ""
          },
          "pricing": {
            "type": "string",
            "maxLength": 10000,
            "title": "Pricing",
            "default": ""
          },
          "team": {
            "type": "string",
            "maxLength": 10000,
            "title": "Team",
            "default": ""
          },
          "faqs": {
            "type": "string",
            "maxLength": 10000,
            "title": "Faqs",
            "default": ""
          },
          "product_offer": {
            "type": "string",
            "maxLength": 10000,
            "title": "Product Offer",
            "default": ""
          },
          "qualification_criteria": {
            "type": "string",
            "maxLength": 10000,
            "title": "Qualification Criteria",
            "default": ""
          },
          "common_objections": {
            "type": "string",
            "maxLength": 10000,
            "title": "Common Objections",
            "default": ""
          },
          "voice_provider": {
            "type": "string",
            "pattern": "^(xai|elevenlabs|openai|gemini|openai_live)$",
            "title": "Voice Provider",
            "default": "xai"
          },
          "agent_type": {
            "anyOf": [
              {
                "type": "string",
                "pattern": "^(receptionist|sdr)$"
              },
              {
                "type": "null"
              }
            ],
            "title": "Agent Type"
          },
          "sales_methodology": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 50
              },
              {
                "type": "null"
              }
            ],
            "title": "Sales Methodology"
          },
          "cta_type": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 50
              },
              {
                "type": "null"
              }
            ],
            "title": "Cta Type"
          }
        },
        "type": "object",
        "required": [
          "business_name"
        ],
        "title": "PreviewPromptRequest",
        "description": "Request to preview the full generated prompt."
      },
      "PreviewPromptResponse": {
        "properties": {
          "system_prompt": {
            "type": "string",
            "title": "System Prompt"
          },
          "greeting": {
            "type": "string",
            "title": "Greeting"
          },
          "recommended_settings": {
            "additionalProperties": true,
            "type": "object",
            "title": "Recommended Settings"
          }
        },
        "type": "object",
        "required": [
          "system_prompt",
          "greeting",
          "recommended_settings"
        ],
        "title": "PreviewPromptResponse",
        "description": "Response with the full generated prompt and recommended settings."
      },
      "ProviderBreakdown": {
        "properties": {
          "provider": {
            "type": "string",
            "title": "Provider"
          },
          "provider_label": {
            "type": "string",
            "title": "Provider Label"
          },
          "calls": {
            "type": "integer",
            "title": "Calls"
          },
          "minutes": {
            "type": "number",
            "title": "Minutes"
          },
          "cost_cents": {
            "type": "integer",
            "title": "Cost Cents"
          },
          "revenue_cents": {
            "type": "integer",
            "title": "Revenue Cents"
          },
          "margin_cents": {
            "type": "integer",
            "title": "Margin Cents"
          }
        },
        "type": "object",
        "required": [
          "provider",
          "provider_label",
          "calls",
          "minutes",
          "cost_cents",
          "revenue_cents",
          "margin_cents"
        ],
        "title": "ProviderBreakdown",
        "description": "Usage breakdown by voice provider."
      },
      "ProviderUsage": {
        "properties": {
          "provider": {
            "type": "string",
            "title": "Provider"
          },
          "provider_label": {
            "type": "string",
            "title": "Provider Label"
          },
          "calls": {
            "type": "integer",
            "title": "Calls"
          },
          "minutes": {
            "type": "number",
            "title": "Minutes"
          },
          "rate_cents": {
            "type": "integer",
            "title": "Rate Cents"
          },
          "cost_cents": {
            "type": "integer",
            "title": "Cost Cents"
          }
        },
        "type": "object",
        "required": [
          "provider",
          "provider_label",
          "calls",
          "minutes",
          "rate_cents",
          "cost_cents"
        ],
        "title": "ProviderUsage",
        "description": "Usage breakdown for a single voice provider."
      },
      "PublicAgentResponse": {
        "properties": {
          "agent_name": {
            "type": "string",
            "title": "Agent Name"
          },
          "business_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Business Name"
          },
          "industry": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Industry"
          },
          "greeting": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Greeting"
          },
          "voice": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Voice"
          },
          "voice_provider": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Voice Provider"
          }
        },
        "type": "object",
        "required": [
          "agent_name"
        ],
        "title": "PublicAgentResponse",
        "description": "Public-facing agent info for the demo page (no sensitive data)."
      },
      "PublicBrandingResponse": {
        "properties": {
          "company_name": {
            "type": "string",
            "title": "Company Name"
          },
          "logo_url": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Logo Url"
          },
          "favicon_url": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Favicon Url"
          },
          "primary_color": {
            "type": "string",
            "title": "Primary Color",
            "default": "#6298B6"
          }
        },
        "type": "object",
        "required": [
          "company_name"
        ],
        "title": "PublicBrandingResponse"
      },
      "PublicCheckoutRequest": {
        "properties": {
          "email": {
            "type": "string",
            "format": "email",
            "title": "Email"
          },
          "plan": {
            "type": "string",
            "enum": [
              "payg",
              "starter",
              "agency",
              "pro"
            ],
            "title": "Plan"
          },
          "billing_period": {
            "type": "string",
            "enum": [
              "monthly",
              "annual"
            ],
            "title": "Billing Period",
            "default": "monthly"
          }
        },
        "type": "object",
        "required": [
          "email",
          "plan"
        ],
        "title": "PublicCheckoutRequest",
        "description": "Request for unauthenticated checkout (Stripe-first signup)."
      },
      "PublicDemoLookResponse": {
        "properties": {
          "color": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Color"
          },
          "position": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Position"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "title": "PublicDemoLookResponse",
        "description": "GET /d/{slug}/look (DAN-613): the saved look and nothing else.\n\nextra=\"forbid\" keeps any other config key from ever reaching this public\nresponse by accident."
      },
      "PublicDemoResponse": {
        "properties": {
          "channel": {
            "type": "string",
            "title": "Channel"
          },
          "config": {
            "additionalProperties": true,
            "type": "object",
            "title": "Config",
            "default": {}
          },
          "name": {
            "type": "string",
            "title": "Name",
            "default": ""
          },
          "agent_name": {
            "type": "string",
            "title": "Agent Name"
          },
          "business_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Business Name"
          },
          "industry": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Industry"
          },
          "greeting": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Greeting"
          },
          "voice": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Voice"
          },
          "voice_provider": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Voice Provider"
          },
          "after_cta_text": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "After Cta Text"
          },
          "after_cta_url": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "After Cta Url"
          },
          "branding": {
            "anyOf": [
              {
                "additionalProperties": true,
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Branding"
          },
          "expires_at": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Expires At"
          },
          "variable_definitions": {
            "anyOf": [
              {
                "items": {
                  "additionalProperties": true,
                  "type": "object"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Variable Definitions"
          }
        },
        "type": "object",
        "required": [
          "channel",
          "agent_name"
        ],
        "title": "PublicDemoResponse",
        "description": "Public-facing demo config for the demo page (no sensitive data)."
      },
      "RecentCall": {
        "properties": {
          "id": {
            "type": "string",
            "title": "Id"
          },
          "from_number": {
            "type": "string",
            "title": "From Number"
          },
          "duration_seconds": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Duration Seconds"
          },
          "status": {
            "type": "string",
            "title": "Status"
          },
          "started_at": {
            "type": "string",
            "format": "date-time",
            "title": "Started At"
          },
          "agent_id": {
            "type": "string",
            "title": "Agent Id"
          },
          "appointment_booked": {
            "type": "boolean",
            "title": "Appointment Booked"
          }
        },
        "type": "object",
        "required": [
          "id",
          "from_number",
          "status",
          "started_at",
          "agent_id",
          "appointment_booked"
        ],
        "title": "RecentCall",
        "description": "Schema for a recent call in the dashboard."
      },
      "RefreshTokenRequest": {
        "properties": {
          "refresh_token": {
            "type": "string",
            "title": "Refresh Token"
          }
        },
        "type": "object",
        "required": [
          "refresh_token"
        ],
        "title": "RefreshTokenRequest",
        "description": "Request body for token refresh."
      },
      "RemoveIntegrationResponse": {
        "properties": {
          "success": {
            "type": "boolean",
            "title": "Success"
          },
          "sub_account_id": {
            "type": "string",
            "format": "uuid",
            "title": "Sub Account Id"
          },
          "integration_id": {
            "type": "string",
            "format": "uuid",
            "title": "Integration Id"
          }
        },
        "type": "object",
        "required": [
          "success",
          "sub_account_id",
          "integration_id"
        ],
        "title": "RemoveIntegrationResponse",
        "description": "Response after removing an integration from sub-account."
      },
      "ResetPasswordRequest": {
        "properties": {
          "token": {
            "type": "string",
            "title": "Token",
            "description": "Password reset token from email link"
          },
          "new_password": {
            "type": "string",
            "minLength": 6,
            "title": "New Password",
            "description": "New password (minimum 6 characters)"
          }
        },
        "type": "object",
        "required": [
          "token",
          "new_password"
        ],
        "title": "ResetPasswordRequest",
        "description": "Request body for resetting password with token."
      },
      "ResourceUsage": {
        "properties": {
          "current": {
            "type": "integer",
            "title": "Current"
          },
          "limit": {
            "type": "integer",
            "title": "Limit"
          },
          "remaining": {
            "type": "integer",
            "title": "Remaining"
          },
          "unlimited": {
            "type": "boolean",
            "title": "Unlimited"
          }
        },
        "type": "object",
        "required": [
          "current",
          "limit",
          "remaining",
          "unlimited"
        ],
        "title": "ResourceUsage",
        "description": "Usage for a single resource type."
      },
      "RewritePromptRequest": {
        "properties": {
          "suggestions": {
            "items": {
              "additionalProperties": true,
              "type": "object"
            },
            "type": "array",
            "minItems": 1,
            "title": "Suggestions",
            "description": "List of suggestion objects from suggest-prompt"
          },
          "model": {
            "type": "string",
            "title": "Model",
            "default": "openai/gpt-5.5"
          }
        },
        "type": "object",
        "required": [
          "suggestions"
        ],
        "title": "RewritePromptRequest",
        "description": "Holistically rewrite the agent's prompt incorporating all suggestions."
      },
      "RichTextCreate": {
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 200,
            "minLength": 1,
            "title": "Name"
          },
          "content": {
            "type": "string",
            "minLength": 1,
            "title": "Content",
            "description": "Rich text / markdown content"
          }
        },
        "type": "object",
        "required": [
          "name",
          "content"
        ],
        "title": "RichTextCreate",
        "description": "Request body for creating a rich text source."
      },
      "RichTextResponse": {
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "title": "Id"
          },
          "collection_id": {
            "type": "string",
            "format": "uuid",
            "title": "Collection Id"
          },
          "name": {
            "type": "string",
            "title": "Name"
          },
          "source_type": {
            "type": "string",
            "title": "Source Type",
            "default": "rich_text"
          },
          "content": {
            "type": "string",
            "title": "Content",
            "default": ""
          },
          "document_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "title": "Document Id"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "title": "Created At"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "title": "Updated At"
          }
        },
        "type": "object",
        "required": [
          "id",
          "collection_id",
          "name",
          "created_at",
          "updated_at"
        ],
        "title": "RichTextResponse",
        "description": "Rich text source response."
      },
      "RichTextUpdate": {
        "properties": {
          "name": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 200
              },
              {
                "type": "null"
              }
            ],
            "title": "Name"
          },
          "content": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Content"
          }
        },
        "type": "object",
        "title": "RichTextUpdate",
        "description": "Update a rich text source."
      },
      "SaveRewrittenPromptRequest": {
        "properties": {
          "rewritten_prompt": {
            "type": "string",
            "minLength": 10,
            "title": "Rewritten Prompt"
          }
        },
        "type": "object",
        "required": [
          "rewritten_prompt"
        ],
        "title": "SaveRewrittenPromptRequest",
        "description": "Save an approved rewritten prompt to the agent."
      },
      "ScenarioCriterion": {
        "properties": {
          "name": {
            "type": "string",
            "title": "Name",
            "description": "Criterion name, e.g. 'Appointment Booked'"
          },
          "description": {
            "type": "string",
            "title": "Description",
            "description": "What the judge evaluates"
          }
        },
        "type": "object",
        "required": [
          "name",
          "description"
        ],
        "title": "ScenarioCriterion"
      },
      "ScenarioRequest": {
        "properties": {
          "scenario_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Scenario Name"
          },
          "persona": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Persona"
          },
          "description": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Description"
          },
          "criteria": {
            "items": {
              "$ref": "#/components/schemas/ScenarioCriterion"
            },
            "type": "array",
            "title": "Criteria",
            "default": []
          },
          "judge_model": {
            "type": "string",
            "title": "Judge Model",
            "default": "openai/gpt-5.5"
          },
          "simulator_model": {
            "type": "string",
            "title": "Simulator Model",
            "default": "openai/gpt-5.4-mini"
          },
          "max_turns": {
            "type": "integer",
            "maximum": 20.0,
            "minimum": 2.0,
            "title": "Max Turns",
            "default": 10
          }
        },
        "type": "object",
        "title": "ScenarioRequest",
        "description": "Run a simulation with a named scenario or custom config."
      },
      "ScheduledCallCreate": {
        "properties": {
          "agent_id": {
            "type": "string",
            "format": "uuid",
            "title": "Agent Id"
          },
          "to_phone_number": {
            "type": "string",
            "pattern": "^\\+[1-9]\\d{1,14}$",
            "title": "To Phone Number",
            "description": "Recipient phone number in E.164 format"
          },
          "scheduled_for": {
            "type": "string",
            "format": "date-time",
            "title": "Scheduled For",
            "description": "When to call (ISO 8601 format, will be stored as UTC)"
          },
          "timezone": {
            "type": "string",
            "title": "Timezone",
            "description": "User's timezone for display purposes",
            "default": "UTC"
          },
          "contact_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Contact Id",
            "description": "GHL contact ID if known"
          },
          "contact_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Contact Name",
            "description": "Contact name for display"
          },
          "phone_number_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "title": "Phone Number Id",
            "description": "Specific phone number to call from (uses agent default if not provided)"
          },
          "is_callback": {
            "type": "boolean",
            "title": "Is Callback",
            "description": "True if this is a return call",
            "default": false
          },
          "previous_call_log_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "title": "Previous Call Log Id",
            "description": "ID of the call that requested this callback"
          },
          "callback_context": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Callback Context",
            "description": "Summary of previous conversation for context-aware greeting"
          }
        },
        "type": "object",
        "required": [
          "agent_id",
          "to_phone_number",
          "scheduled_for"
        ],
        "title": "ScheduledCallCreate",
        "description": "Schema for creating a scheduled call."
      },
      "ScheduledCallListResponse": {
        "properties": {
          "scheduled_calls": {
            "items": {
              "$ref": "#/components/schemas/ScheduledCallResponse"
            },
            "type": "array",
            "title": "Scheduled Calls"
          },
          "total": {
            "type": "integer",
            "title": "Total"
          }
        },
        "type": "object",
        "required": [
          "scheduled_calls",
          "total"
        ],
        "title": "ScheduledCallListResponse",
        "description": "Response schema for listing scheduled calls."
      },
      "ScheduledCallResponse": {
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "title": "Id"
          },
          "tenant_id": {
            "type": "string",
            "format": "uuid",
            "title": "Tenant Id"
          },
          "agent_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "title": "Agent Id"
          },
          "agent_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Agent Name"
          },
          "phone_number_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "title": "Phone Number Id"
          },
          "from_phone_number": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "From Phone Number"
          },
          "contact_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Contact Id"
          },
          "contact_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Contact Name"
          },
          "to_phone_number": {
            "type": "string",
            "title": "To Phone Number"
          },
          "scheduled_for": {
            "type": "string",
            "format": "date-time",
            "title": "Scheduled For"
          },
          "timezone": {
            "type": "string",
            "title": "Timezone"
          },
          "status": {
            "type": "string",
            "title": "Status"
          },
          "is_callback": {
            "type": "boolean",
            "title": "Is Callback",
            "default": false
          },
          "previous_call_log_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "title": "Previous Call Log Id"
          },
          "callback_context": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Callback Context"
          },
          "call_log_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "title": "Call Log Id"
          },
          "attempts": {
            "type": "integer",
            "title": "Attempts",
            "default": 0
          },
          "last_error": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Last Error"
          },
          "dialed_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Dialed At"
          },
          "source": {
            "type": "string",
            "title": "Source",
            "default": "ai_function"
          },
          "confidence": {
            "type": "number",
            "title": "Confidence",
            "default": 1.0
          },
          "created_by": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "title": "Created By"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "title": "Created At"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "title": "Updated At"
          }
        },
        "type": "object",
        "required": [
          "id",
          "tenant_id",
          "to_phone_number",
          "scheduled_for",
          "timezone",
          "status",
          "created_at",
          "updated_at"
        ],
        "title": "ScheduledCallResponse",
        "description": "Response schema for a scheduled call."
      },
      "ScheduledCallRetry": {
        "properties": {
          "scheduled_for": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Scheduled For",
            "description": "New time to schedule. If not provided, schedules immediately."
          }
        },
        "type": "object",
        "title": "ScheduledCallRetry",
        "description": "Schema for retrying a failed scheduled call."
      },
      "ScheduledCallUpdate": {
        "properties": {
          "scheduled_for": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Scheduled For"
          },
          "timezone": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Timezone"
          },
          "status": {
            "anyOf": [
              {
                "type": "string",
                "enum": [
                  "pending",
                  "cancelled"
                ]
              },
              {
                "type": "null"
              }
            ],
            "title": "Status"
          },
          "contact_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Contact Name"
          }
        },
        "type": "object",
        "title": "ScheduledCallUpdate",
        "description": "Schema for updating a scheduled call."
      },
      "ScrapeWebsiteRequest": {
        "properties": {
          "url": {
            "type": "string",
            "title": "Url",
            "description": "Website URL to scrape"
          }
        },
        "type": "object",
        "required": [
          "url"
        ],
        "title": "ScrapeWebsiteRequest",
        "description": "Request to scrape a website and extract business info."
      },
      "ScrapeWebsiteResponse": {
        "properties": {
          "business_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Business Name"
          },
          "industry": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Industry"
          },
          "description": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Description"
          },
          "services": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Services"
          },
          "pricing": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Pricing"
          },
          "team": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Team"
          },
          "faqs": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Faqs"
          },
          "urls_scraped": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Urls Scraped"
          }
        },
        "type": "object",
        "title": "ScrapeWebsiteResponse",
        "description": "Extracted business information from a website."
      },
      "ScreenshotRequest": {
        "properties": {
          "url": {
            "type": "string",
            "title": "Url",
            "description": "Website URL to screenshot"
          },
          "width": {
            "type": "integer",
            "maximum": 3840.0,
            "minimum": 320.0,
            "title": "Width",
            "default": 1280
          },
          "height": {
            "type": "integer",
            "maximum": 2160.0,
            "minimum": 240.0,
            "title": "Height",
            "default": 800
          },
          "full_page": {
            "type": "boolean",
            "title": "Full Page",
            "default": false
          }
        },
        "type": "object",
        "required": [
          "url"
        ],
        "title": "ScreenshotRequest",
        "description": "Request to capture a website screenshot."
      },
      "ScreenshotResponse": {
        "properties": {
          "screenshot_url": {
            "type": "string",
            "title": "Screenshot Url"
          },
          "width": {
            "type": "integer",
            "title": "Width"
          },
          "height": {
            "type": "integer",
            "title": "Height"
          }
        },
        "type": "object",
        "required": [
          "screenshot_url",
          "width",
          "height"
        ],
        "title": "ScreenshotResponse",
        "description": "Screenshot capture result."
      },
      "SearchRequest": {
        "properties": {
          "query": {
            "type": "string",
            "maxLength": 500,
            "minLength": 1,
            "title": "Query"
          },
          "max_results": {
            "type": "integer",
            "maximum": 20.0,
            "minimum": 1.0,
            "title": "Max Results",
            "default": 5
          }
        },
        "type": "object",
        "required": [
          "query"
        ],
        "title": "SearchRequest",
        "description": "Request body for searching documents."
      },
      "SearchResponse": {
        "properties": {
          "results": {
            "items": {
              "$ref": "#/components/schemas/SearchResult"
            },
            "type": "array",
            "title": "Results"
          },
          "query": {
            "type": "string",
            "title": "Query"
          }
        },
        "type": "object",
        "required": [
          "results",
          "query"
        ],
        "title": "SearchResponse",
        "description": "Search results response."
      },
      "SearchResult": {
        "properties": {
          "document_id": {
            "type": "string",
            "title": "Document Id"
          },
          "filename": {
            "type": "string",
            "title": "Filename"
          },
          "content": {
            "type": "string",
            "title": "Content"
          },
          "score": {
            "type": "number",
            "title": "Score"
          }
        },
        "type": "object",
        "required": [
          "document_id",
          "filename",
          "content",
          "score"
        ],
        "title": "SearchResult",
        "description": "A single search result."
      },
      "SequenceCreate": {
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 255,
            "minLength": 2,
            "title": "Name"
          },
          "description": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 2000
              },
              {
                "type": "null"
              }
            ],
            "title": "Description"
          },
          "agent_id": {
            "type": "string",
            "format": "uuid",
            "title": "Agent Id"
          },
          "phone_number_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "title": "Phone Number Id"
          },
          "pool_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "title": "Pool Id"
          },
          "active_tag": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 255
              },
              {
                "type": "null"
              }
            ],
            "title": "Active Tag"
          },
          "on_reply_tag": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 255
              },
              {
                "type": "null"
              }
            ],
            "title": "On Reply Tag",
            "description": "GHL tag applied to the contact when they reply (fires reply-triggered downstream workflows, e.g. the demo). Resolved via the tenant's GHL integration."
          },
          "continuous_add": {
            "type": "boolean",
            "title": "Continuous Add",
            "default": true
          },
          "steps": {
            "items": {
              "$ref": "#/components/schemas/SequenceStep"
            },
            "type": "array",
            "minItems": 1,
            "title": "Steps"
          },
          "max_attempts": {
            "type": "integer",
            "maximum": 20.0,
            "minimum": 1.0,
            "title": "Max Attempts",
            "default": 6
          },
          "stop_on_booking": {
            "type": "boolean",
            "title": "Stop On Booking",
            "default": true
          },
          "stop_on_reply": {
            "type": "boolean",
            "title": "Stop On Reply",
            "default": false
          },
          "operating_hours": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/OperatingHours"
              },
              {
                "type": "null"
              }
            ]
          },
          "template_id": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 100
              },
              {
                "type": "null"
              }
            ],
            "title": "Template Id"
          },
          "qualification_criteria": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 5000
              },
              {
                "type": "null"
              }
            ],
            "title": "Qualification Criteria"
          },
          "daily_budget_override": {
            "anyOf": [
              {
                "type": "integer",
                "maximum": 1000.0,
                "minimum": 1.0
              },
              {
                "type": "null"
              }
            ],
            "title": "Daily Budget Override"
          },
          "new_pct_override": {
            "anyOf": [
              {
                "type": "integer",
                "maximum": 100.0,
                "minimum": 0.0
              },
              {
                "type": "null"
              }
            ],
            "title": "New Pct Override"
          },
          "allow_budget_rollover_override": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Allow Budget Rollover Override"
          },
          "budget_reset_timezone_override": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Budget Reset Timezone Override"
          }
        },
        "type": "object",
        "required": [
          "name",
          "agent_id",
          "steps"
        ],
        "title": "SequenceCreate"
      },
      "SequenceListResponse": {
        "properties": {
          "sequences": {
            "items": {
              "$ref": "#/components/schemas/SequenceResponse"
            },
            "type": "array",
            "title": "Sequences"
          },
          "total": {
            "type": "integer",
            "title": "Total"
          },
          "totals": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/SequenceTotals"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "type": "object",
        "required": [
          "sequences",
          "total"
        ],
        "title": "SequenceListResponse"
      },
      "SequenceResponse": {
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "title": "Id"
          },
          "tenant_id": {
            "type": "string",
            "format": "uuid",
            "title": "Tenant Id"
          },
          "name": {
            "type": "string",
            "title": "Name"
          },
          "description": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Description"
          },
          "agent_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "title": "Agent Id"
          },
          "phone_number_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "title": "Phone Number Id"
          },
          "pool_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "title": "Pool Id"
          },
          "active_tag": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Active Tag"
          },
          "on_reply_tag": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "On Reply Tag"
          },
          "continuous_add": {
            "type": "boolean",
            "title": "Continuous Add",
            "default": true
          },
          "steps": {
            "items": {
              "additionalProperties": true,
              "type": "object"
            },
            "type": "array",
            "title": "Steps"
          },
          "max_attempts": {
            "type": "integer",
            "title": "Max Attempts"
          },
          "stop_on_booking": {
            "type": "boolean",
            "title": "Stop On Booking"
          },
          "stop_on_reply": {
            "type": "boolean",
            "title": "Stop On Reply"
          },
          "is_active": {
            "type": "boolean",
            "title": "Is Active"
          },
          "operating_hours": {
            "anyOf": [
              {
                "additionalProperties": true,
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Operating Hours"
          },
          "template_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Template Id"
          },
          "qualification_criteria": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Qualification Criteria"
          },
          "daily_budget_override": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Daily Budget Override"
          },
          "new_pct_override": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "New Pct Override"
          },
          "allow_budget_rollover_override": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Allow Budget Rollover Override"
          },
          "budget_reset_timezone_override": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Budget Reset Timezone Override"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "title": "Created At"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "title": "Updated At"
          },
          "agent_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Agent Name"
          },
          "phone_number": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Phone Number"
          },
          "enrolled_count": {
            "type": "integer",
            "title": "Enrolled Count",
            "default": 0
          },
          "active_count": {
            "type": "integer",
            "title": "Active Count",
            "default": 0
          },
          "receiving_steps_count": {
            "type": "integer",
            "title": "Receiving Steps Count",
            "default": 0
          },
          "booked_count": {
            "type": "integer",
            "title": "Booked Count",
            "default": 0
          },
          "interested_count": {
            "type": "integer",
            "title": "Interested Count",
            "default": 0
          },
          "qualified_count": {
            "type": "integer",
            "title": "Qualified Count",
            "default": 0
          },
          "not_qualified_count": {
            "type": "integer",
            "title": "Not Qualified Count",
            "default": 0
          },
          "booking_rate": {
            "type": "number",
            "title": "Booking Rate",
            "default": 0.0
          }
        },
        "type": "object",
        "required": [
          "id",
          "tenant_id",
          "name",
          "steps",
          "max_attempts",
          "stop_on_booking",
          "stop_on_reply",
          "is_active",
          "created_at",
          "updated_at"
        ],
        "title": "SequenceResponse"
      },
      "SequenceStats": {
        "properties": {
          "enrolled_count": {
            "type": "integer",
            "title": "Enrolled Count"
          },
          "active_count": {
            "type": "integer",
            "title": "Active Count"
          },
          "completed_count": {
            "type": "integer",
            "title": "Completed Count"
          },
          "booked_count": {
            "type": "integer",
            "title": "Booked Count"
          },
          "cancelled_count": {
            "type": "integer",
            "title": "Cancelled Count"
          },
          "opted_out_count": {
            "type": "integer",
            "title": "Opted Out Count"
          },
          "interested_count": {
            "type": "integer",
            "title": "Interested Count",
            "default": 0
          },
          "qualified_count": {
            "type": "integer",
            "title": "Qualified Count",
            "default": 0
          },
          "not_qualified_count": {
            "type": "integer",
            "title": "Not Qualified Count",
            "default": 0
          },
          "bad_number_count": {
            "type": "integer",
            "title": "Bad Number Count",
            "default": 0
          },
          "bad_numbers": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Bad Numbers",
            "default": []
          },
          "replied_count": {
            "type": "integer",
            "title": "Replied Count",
            "default": 0
          },
          "reply_rate": {
            "type": "number",
            "title": "Reply Rate",
            "default": 0.0
          },
          "booking_rate": {
            "type": "number",
            "title": "Booking Rate"
          },
          "in_flight_count": {
            "type": "integer",
            "title": "In Flight Count",
            "default": 0
          },
          "receiving_steps_count": {
            "type": "integer",
            "title": "Receiving Steps Count",
            "default": 0
          }
        },
        "type": "object",
        "required": [
          "enrolled_count",
          "active_count",
          "completed_count",
          "booked_count",
          "cancelled_count",
          "opted_out_count",
          "booking_rate"
        ],
        "title": "SequenceStats"
      },
      "SequenceStep": {
        "properties": {
          "type": {
            "$ref": "#/components/schemas/StepType"
          },
          "delay_minutes": {
            "type": "integer",
            "minimum": 0.0,
            "title": "Delay Minutes",
            "description": "Minutes to wait before executing this step"
          },
          "message": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 1600
              },
              {
                "type": "null"
              }
            ],
            "title": "Message",
            "description": "Message body (text and voicemail_drop steps)"
          },
          "config": {
            "additionalProperties": true,
            "type": "object",
            "title": "Config",
            "description": "Step-specific config"
          },
          "id": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 64
              },
              {
                "type": "null"
              }
            ],
            "title": "Id",
            "description": "Stable step id. Send back the id you read so contacts partway through the sequence stay on the right step after an edit. Leave it out on a new step."
          }
        },
        "type": "object",
        "required": [
          "type",
          "delay_minutes"
        ],
        "title": "SequenceStep",
        "description": "Single step in a sequence. Stored as JSONB array element."
      },
      "SequenceTotals": {
        "properties": {
          "enrolled_count": {
            "type": "integer",
            "title": "Enrolled Count",
            "default": 0
          },
          "active_count": {
            "type": "integer",
            "title": "Active Count",
            "default": 0
          },
          "receiving_steps_count": {
            "type": "integer",
            "title": "Receiving Steps Count",
            "default": 0
          },
          "booked_count": {
            "type": "integer",
            "title": "Booked Count",
            "default": 0
          },
          "replied_count": {
            "type": "integer",
            "title": "Replied Count",
            "default": 0
          },
          "booking_rate": {
            "type": "number",
            "title": "Booking Rate",
            "default": 0.0
          },
          "reply_rate": {
            "type": "number",
            "title": "Reply Rate",
            "default": 0.0
          }
        },
        "type": "object",
        "title": "SequenceTotals",
        "description": "Totals across every sequence of the sub-account, not only the page (DAN-167 L-13).\n\nRates are weighted by contacts: booked / enrolled over all sequences."
      },
      "SequenceUpdate": {
        "properties": {
          "name": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 255,
                "minLength": 2
              },
              {
                "type": "null"
              }
            ],
            "title": "Name"
          },
          "description": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 2000
              },
              {
                "type": "null"
              }
            ],
            "title": "Description"
          },
          "agent_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "title": "Agent Id"
          },
          "phone_number_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "title": "Phone Number Id"
          },
          "pool_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "title": "Pool Id"
          },
          "active_tag": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 255
              },
              {
                "type": "null"
              }
            ],
            "title": "Active Tag"
          },
          "on_reply_tag": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 255
              },
              {
                "type": "null"
              }
            ],
            "title": "On Reply Tag"
          },
          "continuous_add": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Continuous Add"
          },
          "steps": {
            "anyOf": [
              {
                "items": {
                  "$ref": "#/components/schemas/SequenceStep"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Steps"
          },
          "max_attempts": {
            "anyOf": [
              {
                "type": "integer",
                "maximum": 20.0,
                "minimum": 1.0
              },
              {
                "type": "null"
              }
            ],
            "title": "Max Attempts"
          },
          "stop_on_booking": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Stop On Booking"
          },
          "stop_on_reply": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Stop On Reply"
          },
          "operating_hours": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/OperatingHours"
              },
              {
                "type": "null"
              }
            ]
          },
          "qualification_criteria": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 5000
              },
              {
                "type": "null"
              }
            ],
            "title": "Qualification Criteria"
          },
          "daily_budget_override": {
            "anyOf": [
              {
                "type": "integer",
                "maximum": 1000.0,
                "minimum": 1.0
              },
              {
                "type": "null"
              }
            ],
            "title": "Daily Budget Override"
          },
          "new_pct_override": {
            "anyOf": [
              {
                "type": "integer",
                "maximum": 100.0,
                "minimum": 0.0
              },
              {
                "type": "null"
              }
            ],
            "title": "New Pct Override"
          },
          "allow_budget_rollover_override": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Allow Budget Rollover Override"
          },
          "budget_reset_timezone_override": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Budget Reset Timezone Override"
          }
        },
        "type": "object",
        "title": "SequenceUpdate"
      },
      "SetupStatusResponse": {
        "properties": {
          "tasks": {
            "additionalProperties": {
              "$ref": "#/components/schemas/TaskStatus"
            },
            "type": "object",
            "title": "Tasks"
          },
          "completed_count": {
            "type": "integer",
            "title": "Completed Count"
          },
          "total_count": {
            "type": "integer",
            "title": "Total Count"
          },
          "required_complete": {
            "type": "boolean",
            "title": "Required Complete"
          },
          "all_complete": {
            "type": "boolean",
            "title": "All Complete"
          }
        },
        "type": "object",
        "required": [
          "tasks",
          "completed_count",
          "total_count",
          "required_complete",
          "all_complete"
        ],
        "title": "SetupStatusResponse",
        "description": "Aggregated setup status derived from actual tenant data."
      },
      "ShareLinkSummary": {
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "title": "Id"
          },
          "agent_id": {
            "type": "string",
            "format": "uuid",
            "title": "Agent Id"
          },
          "agent_name": {
            "type": "string",
            "title": "Agent Name"
          },
          "slug": {
            "type": "string",
            "title": "Slug"
          },
          "share_url": {
            "type": "string",
            "title": "Share Url"
          },
          "view_count": {
            "type": "integer",
            "title": "View Count",
            "default": 0
          },
          "call_count": {
            "type": "integer",
            "title": "Call Count",
            "default": 0
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "title": "Created At"
          },
          "expires_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Expires At"
          }
        },
        "type": "object",
        "required": [
          "id",
          "agent_id",
          "agent_name",
          "slug",
          "share_url",
          "created_at"
        ],
        "title": "ShareLinkSummary",
        "description": "Summary of a share link for the demo management view."
      },
      "SignupRequest": {
        "properties": {
          "email": {
            "type": "string",
            "format": "email",
            "title": "Email"
          },
          "password": {
            "type": "string",
            "minLength": 6,
            "title": "Password",
            "description": "Minimum 6 characters (Supabase requirement)"
          },
          "company_name": {
            "type": "string",
            "maxLength": 255,
            "minLength": 2,
            "title": "Company Name"
          },
          "account_type": {
            "type": "string",
            "enum": [
              "direct",
              "agency"
            ],
            "title": "Account Type",
            "default": "direct"
          },
          "tos_accepted": {
            "type": "boolean",
            "title": "Tos Accepted",
            "description": "User must accept Terms of Service and Privacy Policy",
            "default": false
          }
        },
        "type": "object",
        "required": [
          "email",
          "password",
          "company_name"
        ],
        "title": "SignupRequest",
        "description": "Request body for user signup."
      },
      "SourceListResponse": {
        "properties": {
          "sources": {
            "items": {
              "$ref": "#/components/schemas/SourceResponse"
            },
            "type": "array",
            "title": "Sources"
          },
          "total": {
            "type": "integer",
            "title": "Total"
          }
        },
        "type": "object",
        "required": [
          "sources",
          "total"
        ],
        "title": "SourceListResponse",
        "description": "List of sources response."
      },
      "SourceResponse": {
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "title": "Id"
          },
          "collection_id": {
            "type": "string",
            "format": "uuid",
            "title": "Collection Id"
          },
          "name": {
            "type": "string",
            "title": "Name"
          },
          "source_type": {
            "type": "string",
            "title": "Source Type"
          },
          "document_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "title": "Document Id"
          },
          "config": {
            "additionalProperties": true,
            "type": "object",
            "title": "Config"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "title": "Created At"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "title": "Updated At"
          }
        },
        "type": "object",
        "required": [
          "id",
          "collection_id",
          "name",
          "source_type",
          "created_at",
          "updated_at"
        ],
        "title": "SourceResponse",
        "description": "Generic source response (for list endpoints)."
      },
      "StatusBreakdown": {
        "properties": {
          "status": {
            "type": "string",
            "title": "Status"
          },
          "count": {
            "type": "integer",
            "title": "Count",
            "default": 0
          }
        },
        "type": "object",
        "required": [
          "status"
        ],
        "title": "StatusBreakdown",
        "description": "Call count grouped by status."
      },
      "StepType": {
        "type": "string",
        "enum": [
          "call",
          "text",
          "wait",
          "voicemail_drop"
        ],
        "title": "StepType"
      },
      "StepUpdateRequest": {
        "properties": {
          "account_type": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Account Type"
          },
          "business_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Business Name"
          },
          "industry": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Industry"
          },
          "connected": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Connected"
          },
          "purchased": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Purchased"
          },
          "created": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Created"
          },
          "completed": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Completed"
          },
          "deployed": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Deployed"
          },
          "skipped": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Skipped"
          },
          "agent_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Agent Id"
          },
          "ghl_integration_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Ghl Integration Id"
          },
          "phone_number_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Phone Number Id"
          },
          "sub_account_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Sub Account Id"
          }
        },
        "type": "object",
        "title": "StepUpdateRequest",
        "description": "Generic step update request."
      },
      "SubAccountAgentInfo": {
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "title": "Id"
          },
          "tenant_id": {
            "type": "string",
            "format": "uuid",
            "title": "Tenant Id"
          },
          "name": {
            "type": "string",
            "title": "Name"
          },
          "is_active": {
            "type": "boolean",
            "title": "Is Active"
          },
          "voice_provider": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Voice Provider"
          },
          "voice": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Voice"
          },
          "phone_count": {
            "type": "integer",
            "title": "Phone Count",
            "default": 0
          },
          "sub_account_name": {
            "type": "string",
            "title": "Sub Account Name"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "title": "Created At"
          }
        },
        "type": "object",
        "required": [
          "id",
          "tenant_id",
          "name",
          "is_active",
          "sub_account_name",
          "created_at"
        ],
        "title": "SubAccountAgentInfo",
        "description": "A lightweight agent summary for the agency cross-account view."
      },
      "SubAccountBillingResponse": {
        "properties": {
          "per_minute_rate_cents": {
            "type": "integer",
            "title": "Per Minute Rate Cents"
          },
          "is_suspended": {
            "type": "boolean",
            "title": "Is Suspended"
          },
          "suspended_reason": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Suspended Reason"
          },
          "agency_name": {
            "type": "string",
            "title": "Agency Name"
          },
          "calls_this_period": {
            "type": "integer",
            "title": "Calls This Period"
          },
          "minutes_this_period": {
            "type": "number",
            "title": "Minutes This Period"
          },
          "cost_this_period_cents": {
            "type": "integer",
            "title": "Cost This Period Cents"
          },
          "usage_by_provider": {
            "items": {
              "$ref": "#/components/schemas/ProviderUsage"
            },
            "type": "array",
            "title": "Usage By Provider",
            "default": []
          },
          "text_messages_count": {
            "type": "integer",
            "title": "Text Messages Count",
            "default": 0
          },
          "text_messages_cost_cents": {
            "type": "integer",
            "title": "Text Messages Cost Cents",
            "default": 0
          },
          "period_start": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Period Start"
          },
          "period_end": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Period End"
          },
          "period_source": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Period Source"
          },
          "call_attempts": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Call Attempts"
          }
        },
        "type": "object",
        "required": [
          "per_minute_rate_cents",
          "is_suspended",
          "agency_name",
          "calls_this_period",
          "minutes_this_period",
          "cost_this_period_cents"
        ],
        "title": "SubAccountBillingResponse",
        "description": "Sub-account's view of their own billing info."
      },
      "SubAccountFunctionInfo": {
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "title": "Id"
          },
          "name": {
            "type": "string",
            "title": "Name"
          },
          "description": {
            "type": "string",
            "title": "Description"
          },
          "webhook_url": {
            "type": "string",
            "title": "Webhook Url"
          },
          "webhook_method": {
            "type": "string",
            "title": "Webhook Method"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "title": "Created At"
          },
          "sub_account_id": {
            "type": "string",
            "format": "uuid",
            "title": "Sub Account Id"
          },
          "sub_account_name": {
            "type": "string",
            "title": "Sub Account Name"
          }
        },
        "type": "object",
        "required": [
          "id",
          "name",
          "description",
          "webhook_url",
          "webhook_method",
          "created_at",
          "sub_account_id",
          "sub_account_name"
        ],
        "title": "SubAccountFunctionInfo",
        "description": "A custom function from a sub-account (for sharing UI)."
      },
      "SubAccountIntegrationInfo": {
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "title": "Id"
          },
          "provider": {
            "type": "string",
            "title": "Provider"
          },
          "provider_account_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Provider Account Id"
          },
          "account_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Account Name"
          },
          "is_active": {
            "type": "boolean",
            "title": "Is Active"
          },
          "assigned_at": {
            "type": "string",
            "format": "date-time",
            "title": "Assigned At"
          }
        },
        "type": "object",
        "required": [
          "id",
          "provider",
          "is_active",
          "assigned_at"
        ],
        "title": "SubAccountIntegrationInfo",
        "description": "Integration assigned to a sub-account."
      },
      "SubAccountIntegrationsResponse": {
        "properties": {
          "has_integrations": {
            "type": "boolean",
            "title": "Has Integrations"
          },
          "integrations": {
            "items": {
              "$ref": "#/components/schemas/IntegrationInfo"
            },
            "type": "array",
            "title": "Integrations",
            "default": []
          },
          "ghl_count": {
            "type": "integer",
            "title": "Ghl Count",
            "default": 0
          },
          "twilio_count": {
            "type": "integer",
            "title": "Twilio Count",
            "default": 0
          }
        },
        "type": "object",
        "required": [
          "has_integrations"
        ],
        "title": "SubAccountIntegrationsResponse",
        "description": "Sub-account's assigned integrations."
      },
      "SubAccountListResponse": {
        "properties": {
          "sub_accounts": {
            "items": {
              "$ref": "#/components/schemas/SubAccountResponse"
            },
            "type": "array",
            "title": "Sub Accounts"
          },
          "total_count": {
            "type": "integer",
            "title": "Total Count"
          }
        },
        "type": "object",
        "required": [
          "sub_accounts",
          "total_count"
        ],
        "title": "SubAccountListResponse",
        "description": "List of sub-accounts."
      },
      "SubAccountResponse": {
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "title": "Id"
          },
          "name": {
            "type": "string",
            "title": "Name"
          },
          "slug": {
            "type": "string",
            "title": "Slug"
          },
          "admin_email": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Admin Email"
          },
          "admin_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Admin Name"
          },
          "is_active": {
            "type": "boolean",
            "title": "Is Active"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "title": "Created At"
          },
          "per_minute_rate_cents": {
            "type": "integer",
            "title": "Per Minute Rate Cents"
          },
          "monthly_platform_fee_cents": {
            "type": "integer",
            "title": "Monthly Platform Fee Cents"
          },
          "is_suspended": {
            "type": "boolean",
            "title": "Is Suspended"
          },
          "suspended_reason": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Suspended Reason"
          },
          "billing_start_day": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Billing Start Day",
            "default": 1
          },
          "upcharge_by_provider": {
            "anyOf": [
              {
                "additionalProperties": {
                  "type": "integer"
                },
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Upcharge By Provider"
          },
          "test_demo_upcharge_by_provider": {
            "anyOf": [
              {
                "additionalProperties": {
                  "type": "integer"
                },
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Test Demo Upcharge By Provider"
          },
          "text_upcharge_by_type": {
            "anyOf": [
              {
                "additionalProperties": {
                  "type": "integer"
                },
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Text Upcharge By Type"
          },
          "integrations": {
            "items": {
              "$ref": "#/components/schemas/SubAccountIntegrationInfo"
            },
            "type": "array",
            "title": "Integrations",
            "default": []
          },
          "integration_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "title": "Integration Id"
          },
          "total_calls": {
            "type": "integer",
            "title": "Total Calls",
            "default": 0
          },
          "total_minutes": {
            "type": "number",
            "title": "Total Minutes",
            "default": 0.0
          },
          "agents_count": {
            "type": "integer",
            "title": "Agents Count",
            "default": 0
          },
          "total_texts": {
            "type": "integer",
            "title": "Total Texts",
            "default": 0
          },
          "sequences_enabled": {
            "type": "boolean",
            "title": "Sequences Enabled",
            "default": true
          },
          "is_paused": {
            "type": "boolean",
            "title": "Is Paused",
            "default": false
          },
          "paused_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Paused At"
          },
          "paused_reason": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Paused Reason"
          },
          "client_payment_failed_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Client Payment Failed At"
          },
          "client_payment_failed_invoice_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Client Payment Failed Invoice Id"
          },
          "client_card_status": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Client Card Status"
          },
          "client_card_last4": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Client Card Last4"
          },
          "client_card_saved_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Client Card Saved At"
          },
          "client_billing_enabled": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Client Billing Enabled"
          },
          "client_billing_email": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Client Billing Email"
          },
          "client_billing_enabled_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Client Billing Enabled At"
          },
          "client_billing_disabled_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Client Billing Disabled At"
          },
          "client_billing_final_start": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Client Billing Final Start"
          },
          "client_billing_unpriced_providers": {
            "anyOf": [
              {
                "items": {
                  "additionalProperties": true,
                  "type": "object"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Client Billing Unpriced Providers"
          },
          "client_billing_rate_gaps": {
            "anyOf": [
              {
                "items": {
                  "additionalProperties": true,
                  "type": "object"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Client Billing Rate Gaps"
          },
          "client_billing_rate_gaps_message": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Client Billing Rate Gaps Message"
          }
        },
        "type": "object",
        "required": [
          "id",
          "name",
          "slug",
          "is_active",
          "created_at",
          "per_minute_rate_cents",
          "monthly_platform_fee_cents",
          "is_suspended"
        ],
        "title": "SubAccountResponse",
        "description": "Sub-account with billing and stats."
      },
      "SubAccountSummary": {
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "title": "Id"
          },
          "name": {
            "type": "string",
            "title": "Name"
          },
          "calls": {
            "type": "integer",
            "title": "Calls"
          },
          "minutes": {
            "type": "number",
            "title": "Minutes"
          },
          "revenue_cents": {
            "type": "integer",
            "title": "Revenue Cents"
          },
          "margin_cents": {
            "type": "integer",
            "title": "Margin Cents"
          },
          "conversion_rate": {
            "type": "number",
            "title": "Conversion Rate"
          },
          "billed_minutes": {
            "type": "integer",
            "title": "Billed Minutes",
            "default": 0
          }
        },
        "type": "object",
        "required": [
          "id",
          "name",
          "calls",
          "minutes",
          "revenue_cents",
          "margin_cents",
          "conversion_rate"
        ],
        "title": "SubAccountSummary",
        "description": "Top sub-account stats for agency dashboard."
      },
      "SubscriptionStatus": {
        "properties": {
          "plan": {
            "type": "string",
            "title": "Plan"
          },
          "status": {
            "type": "string",
            "title": "Status"
          },
          "current_period_start": {
            "type": "string",
            "format": "date-time",
            "title": "Current Period Start"
          },
          "current_period_end": {
            "type": "string",
            "format": "date-time",
            "title": "Current Period End"
          },
          "cancel_at_period_end": {
            "type": "boolean",
            "title": "Cancel At Period End"
          },
          "has_stripe_subscription": {
            "type": "boolean",
            "title": "Has Stripe Subscription",
            "default": false
          },
          "usage": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/UsageSummary"
              },
              {
                "type": "null"
              }
            ]
          },
          "trial": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/TrialInfo"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "type": "object",
        "required": [
          "plan",
          "status",
          "current_period_start",
          "current_period_end",
          "cancel_at_period_end"
        ],
        "title": "SubscriptionStatus",
        "description": "Current subscription status and usage."
      },
      "SuggestFunctionsRequest": {
        "properties": {
          "industry": {
            "type": "string",
            "maxLength": 50,
            "minLength": 1,
            "title": "Industry",
            "description": "Business industry"
          },
          "agent_mode": {
            "type": "string",
            "pattern": "^(inbound|outbound|both)$",
            "title": "Agent Mode",
            "description": "Agent mode: inbound, outbound, or both",
            "default": "inbound"
          },
          "description": {
            "type": "string",
            "maxLength": 1000,
            "title": "Description",
            "description": "Business description for context",
            "default": ""
          },
          "has_ghl": {
            "type": "boolean",
            "title": "Has Ghl",
            "description": "Whether GoHighLevel CRM is connected",
            "default": false
          },
          "system_prompt": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 50000
              },
              {
                "type": "null"
              }
            ],
            "title": "System Prompt",
            "description": "Existing system prompt for deeper context"
          }
        },
        "type": "object",
        "required": [
          "industry"
        ],
        "title": "SuggestFunctionsRequest",
        "description": "Request to get AI-powered function suggestions for an agent."
      },
      "SuggestFunctionsResponse": {
        "properties": {
          "suggestions": {
            "items": {
              "$ref": "#/components/schemas/FunctionSuggestion"
            },
            "type": "array",
            "title": "Suggestions"
          }
        },
        "type": "object",
        "required": [
          "suggestions"
        ],
        "title": "SuggestFunctionsResponse",
        "description": "Response with AI-generated function suggestions."
      },
      "SuggestPromptRequest": {
        "properties": {
          "analysis_ids": {
            "items": {
              "type": "string",
              "format": "uuid"
            },
            "type": "array",
            "title": "Analysis Ids",
            "description": "Call analysis IDs to base suggestions on",
            "default": []
          },
          "simulation_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "title": "Simulation Id"
          },
          "failures": {
            "items": {
              "additionalProperties": true,
              "type": "object"
            },
            "type": "array",
            "title": "Failures",
            "description": "Inline failure data: [{name, reasoning, call_summary}]",
            "default": []
          },
          "model": {
            "type": "string",
            "title": "Model",
            "default": "openai/gpt-5.5"
          }
        },
        "type": "object",
        "title": "SuggestPromptRequest",
        "description": "Generate prompt improvements from analysis."
      },
      "TableSourceCreate": {
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 200,
            "minLength": 1,
            "title": "Name"
          },
          "headers": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "minItems": 1,
            "title": "Headers"
          },
          "table_data": {
            "items": {
              "items": {
                "type": "string"
              },
              "type": "array"
            },
            "type": "array",
            "title": "Table Data"
          }
        },
        "type": "object",
        "required": [
          "name",
          "headers"
        ],
        "title": "TableSourceCreate",
        "description": "Request body for creating a table source."
      },
      "TableSourceResponse": {
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "title": "Id"
          },
          "collection_id": {
            "type": "string",
            "format": "uuid",
            "title": "Collection Id"
          },
          "name": {
            "type": "string",
            "title": "Name"
          },
          "source_type": {
            "type": "string",
            "title": "Source Type",
            "default": "table"
          },
          "headers": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Headers"
          },
          "table_data": {
            "items": {
              "items": {
                "type": "string"
              },
              "type": "array"
            },
            "type": "array",
            "title": "Table Data"
          },
          "document_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "title": "Document Id"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "title": "Created At"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "title": "Updated At"
          }
        },
        "type": "object",
        "required": [
          "id",
          "collection_id",
          "name",
          "created_at",
          "updated_at"
        ],
        "title": "TableSourceResponse",
        "description": "Table source response."
      },
      "TableSourceUpdate": {
        "properties": {
          "name": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 200
              },
              {
                "type": "null"
              }
            ],
            "title": "Name"
          },
          "headers": {
            "anyOf": [
              {
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Headers"
          },
          "table_data": {
            "anyOf": [
              {
                "items": {
                  "items": {
                    "type": "string"
                  },
                  "type": "array"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Table Data"
          }
        },
        "type": "object",
        "title": "TableSourceUpdate",
        "description": "Update a table source."
      },
      "TaskStatus": {
        "properties": {
          "complete": {
            "type": "boolean",
            "title": "Complete"
          },
          "detail": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Detail"
          }
        },
        "type": "object",
        "required": [
          "complete"
        ],
        "title": "TaskStatus",
        "description": "Status of a single setup task."
      },
      "TenantDetailResponse": {
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "title": "Id"
          },
          "name": {
            "type": "string",
            "title": "Name"
          },
          "slug": {
            "type": "string",
            "title": "Slug"
          },
          "tenant_type": {
            "type": "string",
            "title": "Tenant Type"
          },
          "plan": {
            "type": "string",
            "title": "Plan"
          },
          "agent_limit": {
            "type": "integer",
            "title": "Agent Limit"
          },
          "sub_account_limit": {
            "type": "integer",
            "title": "Sub Account Limit"
          },
          "is_active": {
            "type": "boolean",
            "title": "Is Active"
          },
          "trial_ends_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Trial Ends At"
          },
          "created_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Created At"
          },
          "stats": {
            "$ref": "#/components/schemas/TenantStats"
          }
        },
        "type": "object",
        "required": [
          "id",
          "name",
          "slug",
          "tenant_type",
          "plan",
          "agent_limit",
          "sub_account_limit",
          "is_active",
          "stats"
        ],
        "title": "TenantDetailResponse",
        "description": "Detailed tenant response with stats."
      },
      "TenantResponse": {
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "title": "Id"
          },
          "name": {
            "type": "string",
            "title": "Name"
          },
          "slug": {
            "type": "string",
            "title": "Slug"
          },
          "tenant_type": {
            "type": "string",
            "title": "Tenant Type"
          },
          "plan": {
            "type": "string",
            "title": "Plan"
          },
          "tier": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Tier"
          },
          "agent_limit": {
            "type": "integer",
            "title": "Agent Limit"
          },
          "sub_account_limit": {
            "type": "integer",
            "title": "Sub Account Limit"
          },
          "is_active": {
            "type": "boolean",
            "title": "Is Active"
          },
          "trial_ends_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Trial Ends At"
          },
          "parent_tenant_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "title": "Parent Tenant Id"
          },
          "stripe_subscription_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Stripe Subscription Id"
          },
          "subscription_status": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Subscription Status"
          },
          "effective_plan": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Effective Plan"
          },
          "white_label_enabled": {
            "type": "boolean",
            "title": "White Label Enabled",
            "default": false
          },
          "sequences_enabled": {
            "type": "boolean",
            "title": "Sequences Enabled",
            "default": true
          }
        },
        "type": "object",
        "required": [
          "id",
          "name",
          "slug",
          "tenant_type",
          "plan",
          "agent_limit",
          "sub_account_limit",
          "is_active"
        ],
        "title": "TenantResponse",
        "description": "Tenant data response."
      },
      "TenantStats": {
        "properties": {
          "total_agents": {
            "type": "integer",
            "title": "Total Agents",
            "default": 0
          },
          "active_agents": {
            "type": "integer",
            "title": "Active Agents",
            "default": 0
          },
          "total_phone_numbers": {
            "type": "integer",
            "title": "Total Phone Numbers",
            "default": 0
          },
          "total_calls_this_month": {
            "type": "integer",
            "title": "Total Calls This Month",
            "default": 0
          },
          "total_minutes_this_month": {
            "type": "number",
            "title": "Total Minutes This Month",
            "default": 0.0
          }
        },
        "type": "object",
        "title": "TenantStats",
        "description": "Tenant usage statistics."
      },
      "TenantUpdate": {
        "properties": {
          "name": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 255,
                "minLength": 2
              },
              {
                "type": "null"
              }
            ],
            "title": "Name"
          },
          "webhook_url": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 2048
              },
              {
                "type": "null"
              }
            ],
            "title": "Webhook Url"
          },
          "webhook_enabled": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Webhook Enabled"
          },
          "ghl_conversation_sync_enabled": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Ghl Conversation Sync Enabled"
          }
        },
        "type": "object",
        "title": "TenantUpdate",
        "description": "Request body for updating tenant settings."
      },
      "TestChatRequest": {
        "properties": {
          "agent_id": {
            "type": "string",
            "format": "uuid",
            "title": "Agent Id",
            "description": "Agent ID to test"
          },
          "messages": {
            "items": {
              "$ref": "#/components/schemas/ChatMessage"
            },
            "type": "array",
            "title": "Messages",
            "description": "Conversation history including new user message"
          }
        },
        "type": "object",
        "required": [
          "agent_id",
          "messages"
        ],
        "title": "TestChatRequest",
        "description": "Request for text-based agent testing."
      },
      "TestChatResponse": {
        "properties": {
          "message": {
            "$ref": "#/components/schemas/ChatMessage",
            "description": "AI assistant response"
          },
          "model": {
            "type": "string",
            "title": "Model",
            "description": "Model used (e.g., grok-2-1212)"
          },
          "usage": {
            "anyOf": [
              {
                "additionalProperties": true,
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Usage",
            "description": "Token usage if available"
          },
          "function_calls": {
            "anyOf": [
              {
                "items": {
                  "$ref": "#/components/schemas/FunctionCallLog"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Function Calls",
            "description": "Function calls made during response generation"
          }
        },
        "type": "object",
        "required": [
          "message",
          "model"
        ],
        "title": "TestChatResponse",
        "description": "Response from text-based agent testing."
      },
      "TestVoiceRequest": {
        "properties": {
          "agent_id": {
            "type": "string",
            "format": "uuid",
            "title": "Agent Id",
            "description": "Agent ID to test"
          },
          "audio_base64": {
            "type": "string",
            "title": "Audio Base64",
            "description": "Base64-encoded PCM16 audio at 24kHz"
          }
        },
        "type": "object",
        "required": [
          "agent_id",
          "audio_base64"
        ],
        "title": "TestVoiceRequest",
        "description": "Request for voice-based agent testing."
      },
      "TestVoiceResponse": {
        "properties": {
          "audio_base64": {
            "type": "string",
            "title": "Audio Base64",
            "description": "Base64-encoded PCM16 audio at 24kHz from AI"
          },
          "transcript": {
            "type": "string",
            "title": "Transcript",
            "description": "Text transcript of AI response"
          },
          "model": {
            "type": "string",
            "title": "Model",
            "description": "Model used (e.g., grok-2-1212)"
          }
        },
        "type": "object",
        "required": [
          "audio_base64",
          "transcript",
          "model"
        ],
        "title": "TestVoiceResponse",
        "description": "Response from voice-based agent testing."
      },
      "TextAssistantCreate": {
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 255,
            "minLength": 2,
            "title": "Name"
          },
          "agent_id": {
            "type": "string",
            "format": "uuid",
            "title": "Agent Id",
            "description": "Link to a voice agent. Required - inherits prompt and functions from agent."
          },
          "active_tag": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 255
              },
              {
                "type": "null"
              }
            ],
            "title": "Active Tag",
            "description": "GHL contact tag that activates this assistant"
          },
          "mode": {
            "type": "string",
            "pattern": "^(always_on|after_hours|manual)$",
            "title": "Mode",
            "default": "always_on"
          },
          "business_hours": {
            "anyOf": [
              {
                "additionalProperties": {
                  "$ref": "#/components/schemas/BusinessHoursDay"
                },
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Business Hours"
          },
          "timezone": {
            "type": "string",
            "title": "Timezone",
            "default": "America/New_York"
          },
          "enabled_channels": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/EnabledChannels"
              },
              {
                "type": "null"
              }
            ]
          },
          "human_takeover_timeout_hours": {
            "type": "integer",
            "maximum": 168.0,
            "minimum": 1.0,
            "title": "Human Takeover Timeout Hours",
            "default": 24
          },
          "delayed_trigger_enabled": {
            "type": "boolean",
            "title": "Delayed Trigger Enabled",
            "default": false
          },
          "schedule_text_back_enabled": {
            "type": "boolean",
            "title": "Schedule Text Back Enabled",
            "default": true
          },
          "ghl_integration_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "title": "Ghl Integration Id"
          },
          "calendar_integration_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "title": "Calendar Integration Id"
          },
          "calendar_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Calendar Id"
          },
          "text_model": {
            "type": "string",
            "title": "Text Model",
            "description": "AI model for text message responses (must be in ALLOWED_TEXT_MODEL_IDS)",
            "default": "claude-haiku-4-5-20251001"
          }
        },
        "type": "object",
        "required": [
          "name",
          "agent_id"
        ],
        "title": "TextAssistantCreate",
        "description": "Request body for creating a text assistant.\n\nText assistants now REQUIRE linking to a voice agent.\nThe agent provides the AI personality (prompt, temperature, greeting)."
      },
      "TextAssistantListResponse": {
        "properties": {
          "assistants": {
            "items": {
              "$ref": "#/components/schemas/TextAssistantResponse"
            },
            "type": "array",
            "title": "Assistants"
          },
          "total": {
            "type": "integer",
            "title": "Total"
          }
        },
        "type": "object",
        "required": [
          "assistants",
          "total"
        ],
        "title": "TextAssistantListResponse",
        "description": "List of text assistants response."
      },
      "TextAssistantResponse": {
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "title": "Id"
          },
          "tenant_id": {
            "type": "string",
            "format": "uuid",
            "title": "Tenant Id"
          },
          "name": {
            "type": "string",
            "title": "Name"
          },
          "is_active": {
            "type": "boolean",
            "title": "Is Active"
          },
          "agent_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "title": "Agent Id"
          },
          "linked_agent": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/LinkedAgentSummary"
              },
              {
                "type": "null"
              }
            ]
          },
          "active_tag": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Active Tag"
          },
          "system_prompt": {
            "type": "string",
            "title": "System Prompt"
          },
          "greeting_message": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Greeting Message"
          },
          "temperature": {
            "type": "number",
            "title": "Temperature"
          },
          "business_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Business Name"
          },
          "industry": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Industry"
          },
          "mode": {
            "type": "string",
            "title": "Mode"
          },
          "business_hours": {
            "additionalProperties": true,
            "type": "object",
            "title": "Business Hours"
          },
          "timezone": {
            "type": "string",
            "title": "Timezone"
          },
          "enabled_channels": {
            "additionalProperties": true,
            "type": "object",
            "title": "Enabled Channels"
          },
          "human_takeover_timeout_hours": {
            "type": "integer",
            "title": "Human Takeover Timeout Hours"
          },
          "delayed_trigger_enabled": {
            "type": "boolean",
            "title": "Delayed Trigger Enabled"
          },
          "schedule_text_back_enabled": {
            "type": "boolean",
            "title": "Schedule Text Back Enabled",
            "default": true
          },
          "ghl_integration_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "title": "Ghl Integration Id"
          },
          "calendar_integration_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "title": "Calendar Integration Id"
          },
          "calendar_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Calendar Id"
          },
          "text_model": {
            "type": "string",
            "title": "Text Model",
            "default": "claude-haiku-4-5-20251001"
          },
          "followup_config": {
            "anyOf": [
              {
                "additionalProperties": true,
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Followup Config"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "title": "Created At"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "title": "Updated At"
          }
        },
        "type": "object",
        "required": [
          "id",
          "tenant_id",
          "name",
          "is_active",
          "system_prompt",
          "temperature",
          "mode",
          "business_hours",
          "timezone",
          "enabled_channels",
          "human_takeover_timeout_hours",
          "delayed_trigger_enabled",
          "created_at",
          "updated_at"
        ],
        "title": "TextAssistantResponse",
        "description": "Text assistant data response."
      },
      "TextAssistantUpdate": {
        "properties": {
          "name": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 255,
                "minLength": 2
              },
              {
                "type": "null"
              }
            ],
            "title": "Name"
          },
          "agent_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "title": "Agent Id"
          },
          "is_active": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Is Active"
          },
          "active_tag": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 255
              },
              {
                "type": "null"
              }
            ],
            "title": "Active Tag",
            "description": "GHL contact tag that activates this assistant"
          },
          "mode": {
            "anyOf": [
              {
                "type": "string",
                "pattern": "^(always_on|after_hours|manual)$"
              },
              {
                "type": "null"
              }
            ],
            "title": "Mode"
          },
          "business_hours": {
            "anyOf": [
              {
                "additionalProperties": {
                  "$ref": "#/components/schemas/BusinessHoursDay"
                },
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Business Hours"
          },
          "timezone": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Timezone"
          },
          "enabled_channels": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/EnabledChannels"
              },
              {
                "type": "null"
              }
            ]
          },
          "human_takeover_timeout_hours": {
            "anyOf": [
              {
                "type": "integer",
                "maximum": 168.0,
                "minimum": 1.0
              },
              {
                "type": "null"
              }
            ],
            "title": "Human Takeover Timeout Hours"
          },
          "delayed_trigger_enabled": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Delayed Trigger Enabled"
          },
          "schedule_text_back_enabled": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Schedule Text Back Enabled"
          },
          "ghl_integration_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "title": "Ghl Integration Id"
          },
          "calendar_integration_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "title": "Calendar Integration Id"
          },
          "calendar_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Calendar Id"
          },
          "text_model": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Text Model"
          },
          "followup_config": {
            "anyOf": [
              {
                "additionalProperties": true,
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Followup Config"
          }
        },
        "type": "object",
        "title": "TextAssistantUpdate",
        "description": "Request body for updating a text assistant.\n\nAllows changing operational settings and optionally the linked agent.\nAI personality fields are managed through the linked agent."
      },
      "TextConversationListResponse": {
        "properties": {
          "conversations": {
            "items": {
              "$ref": "#/components/schemas/TextConversationResponse"
            },
            "type": "array",
            "title": "Conversations"
          },
          "total": {
            "type": "integer",
            "title": "Total"
          }
        },
        "type": "object",
        "required": [
          "conversations",
          "total"
        ],
        "title": "TextConversationListResponse",
        "description": "Response schema for listing conversations."
      },
      "TextConversationResponse": {
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "title": "Id"
          },
          "tenant_id": {
            "type": "string",
            "format": "uuid",
            "title": "Tenant Id"
          },
          "text_assistant_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "title": "Text Assistant Id"
          },
          "assistant_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Assistant Name"
          },
          "assistant_names": {
            "anyOf": [
              {
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Assistant Names"
          },
          "ghl_conversation_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Ghl Conversation Id"
          },
          "contact_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Contact Name"
          },
          "ghl_contact_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Ghl Contact Id"
          },
          "channel": {
            "type": "string",
            "title": "Channel"
          },
          "is_ai_active": {
            "type": "boolean",
            "title": "Is Ai Active"
          },
          "last_inbound_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Last Inbound At"
          },
          "last_outbound_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Last Outbound At"
          },
          "last_human_reply_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Last Human Reply At"
          },
          "message_count": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Message Count"
          },
          "function_call_count": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Function Call Count"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "title": "Created At"
          },
          "updated_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Updated At"
          }
        },
        "type": "object",
        "required": [
          "id",
          "tenant_id",
          "channel",
          "is_ai_active",
          "created_at"
        ],
        "title": "TextConversationResponse",
        "description": "Response schema for a text conversation."
      },
      "TextDefaultsResponse": {
        "properties": {
          "defaults": {
            "additionalProperties": true,
            "type": "object",
            "title": "Defaults"
          }
        },
        "type": "object",
        "required": [
          "defaults"
        ],
        "title": "TextDefaultsResponse",
        "description": "Response with default text assistant settings."
      },
      "TextMessageListResponse": {
        "properties": {
          "messages": {
            "items": {
              "$ref": "#/components/schemas/TextMessageResponse"
            },
            "type": "array",
            "title": "Messages"
          },
          "total": {
            "type": "integer",
            "title": "Total"
          }
        },
        "type": "object",
        "required": [
          "messages",
          "total"
        ],
        "title": "TextMessageListResponse",
        "description": "Response schema for listing messages in a conversation."
      },
      "TextMessageResponse": {
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "title": "Id"
          },
          "conversation_id": {
            "type": "string",
            "format": "uuid",
            "title": "Conversation Id"
          },
          "role": {
            "type": "string",
            "title": "Role"
          },
          "content": {
            "type": "string",
            "title": "Content"
          },
          "function_calls": {
            "anyOf": [
              {
                "items": {
                  "$ref": "#/components/schemas/FunctionCallEntry"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Function Calls"
          },
          "channel": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Channel"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "title": "Created At"
          }
        },
        "type": "object",
        "required": [
          "id",
          "conversation_id",
          "role",
          "content",
          "created_at"
        ],
        "title": "TextMessageResponse",
        "description": "Response schema for a single text message."
      },
      "TextPreviewPromptRequest": {
        "properties": {
          "business_name": {
            "type": "string",
            "maxLength": 100,
            "minLength": 1,
            "title": "Business Name"
          },
          "assistant_name": {
            "type": "string",
            "maxLength": 50,
            "minLength": 1,
            "title": "Assistant Name",
            "default": "Alex"
          },
          "industry": {
            "type": "string",
            "maxLength": 50,
            "title": "Industry",
            "default": ""
          },
          "description": {
            "type": "string",
            "maxLength": 1000,
            "title": "Description",
            "default": ""
          },
          "services": {
            "type": "string",
            "maxLength": 2000,
            "title": "Services",
            "default": ""
          },
          "pricing": {
            "type": "string",
            "maxLength": 2000,
            "title": "Pricing",
            "default": ""
          },
          "team": {
            "type": "string",
            "maxLength": 1000,
            "title": "Team",
            "default": ""
          },
          "faqs": {
            "type": "string",
            "maxLength": 3000,
            "title": "Faqs",
            "default": ""
          }
        },
        "type": "object",
        "required": [
          "business_name"
        ],
        "title": "TextPreviewPromptRequest",
        "description": "Request to preview the full generated text assistant prompt."
      },
      "TextPreviewPromptResponse": {
        "properties": {
          "system_prompt": {
            "type": "string",
            "title": "System Prompt"
          },
          "greeting_message": {
            "type": "string",
            "title": "Greeting Message"
          },
          "recommended_settings": {
            "additionalProperties": true,
            "type": "object",
            "title": "Recommended Settings"
          }
        },
        "type": "object",
        "required": [
          "system_prompt",
          "greeting_message",
          "recommended_settings"
        ],
        "title": "TextPreviewPromptResponse",
        "description": "Response with the full generated prompt and recommended settings."
      },
      "TierLimitsResponse": {
        "properties": {
          "tier": {
            "type": "string",
            "title": "Tier"
          },
          "agents": {
            "$ref": "#/components/schemas/ResourceUsage"
          },
          "sub_accounts": {
            "$ref": "#/components/schemas/ResourceUsage"
          },
          "team_members": {
            "$ref": "#/components/schemas/ResourceUsage"
          },
          "share_links": {
            "$ref": "#/components/schemas/ResourceUsage",
            "default": {
              "current": 0,
              "limit": 0,
              "remaining": 0,
              "unlimited": false
            }
          },
          "text_assistant_available": {
            "type": "boolean",
            "title": "Text Assistant Available",
            "default": false
          },
          "demo_suite_available": {
            "type": "boolean",
            "title": "Demo Suite Available",
            "default": false
          },
          "simulation_suite_available": {
            "type": "boolean",
            "title": "Simulation Suite Available",
            "default": false
          },
          "call_analysis_available": {
            "type": "boolean",
            "title": "Call Analysis Available",
            "default": false
          },
          "api_access": {
            "type": "boolean",
            "title": "Api Access",
            "default": false
          },
          "api_scope": {
            "type": "string",
            "title": "Api Scope",
            "default": "none"
          },
          "voice_rate_cents": {
            "type": "integer",
            "title": "Voice Rate Cents",
            "default": 0
          },
          "premium_voice_rate_cents": {
            "type": "integer",
            "title": "Premium Voice Rate Cents",
            "default": 0
          },
          "client_billing_included": {
            "type": "boolean",
            "title": "Client Billing Included",
            "default": false
          }
        },
        "type": "object",
        "required": [
          "tier",
          "agents",
          "sub_accounts",
          "team_members"
        ],
        "title": "TierLimitsResponse",
        "description": "Current tier limits and usage for a tenant."
      },
      "TrialInfo": {
        "properties": {
          "is_trialing": {
            "type": "boolean",
            "title": "Is Trialing"
          },
          "trial_ends_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Trial Ends At"
          },
          "days_remaining": {
            "type": "integer",
            "title": "Days Remaining"
          },
          "minutes_used": {
            "type": "number",
            "title": "Minutes Used"
          },
          "minutes_cap": {
            "type": "integer",
            "title": "Minutes Cap"
          },
          "minutes_remaining": {
            "type": "number",
            "title": "Minutes Remaining"
          },
          "cap_exceeded": {
            "type": "boolean",
            "title": "Cap Exceeded"
          }
        },
        "type": "object",
        "required": [
          "is_trialing",
          "days_remaining",
          "minutes_used",
          "minutes_cap",
          "minutes_remaining",
          "cap_exceeded"
        ],
        "title": "TrialInfo",
        "description": "7-day trial state (FORGE/trial-7day-minute-cap).\n\nAdditive and optional: null for every tenant that is not in a REAL Stripe\ntrial (subscription id present AND status 'trialing'), which includes the\nhundreds of legacy rows that merely default to subscription_status\n='trialing' without ever having paid.\n\nminutes_used is pooled across the agency root and all of its sub-accounts,\nand is produced by the same function the runtime gate uses, so the number\nshown here is always the number a user gets blocked at."
      },
      "TwilioCredentialsRequest": {
        "properties": {
          "account_name": {
            "type": "string",
            "maxLength": 100,
            "minLength": 1,
            "title": "Account Name",
            "description": "Friendly name for this Twilio account"
          },
          "account_sid": {
            "type": "string",
            "maxLength": 34,
            "minLength": 34,
            "title": "Account Sid",
            "description": "Twilio Account SID (ACxxxxxx...)"
          },
          "auth_token": {
            "type": "string",
            "minLength": 32,
            "title": "Auth Token",
            "description": "Twilio Auth Token"
          }
        },
        "type": "object",
        "required": [
          "account_name",
          "account_sid",
          "auth_token"
        ],
        "title": "TwilioCredentialsRequest",
        "description": "Request schema for connecting Twilio account."
      },
      "UnreadCountResponse": {
        "properties": {
          "unread_count": {
            "type": "integer",
            "title": "Unread Count"
          }
        },
        "type": "object",
        "required": [
          "unread_count"
        ],
        "title": "UnreadCountResponse",
        "description": "Lightweight unread count for badge polling."
      },
      "UpcomingInvoiceResponse": {
        "properties": {
          "has_upcoming": {
            "type": "boolean",
            "title": "Has Upcoming"
          },
          "amount_due": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Amount Due"
          },
          "amount_due_formatted": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Amount Due Formatted"
          },
          "currency": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Currency"
          },
          "period_start": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Period Start"
          },
          "period_end": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Period End"
          },
          "lines": {
            "anyOf": [
              {
                "items": {
                  "additionalProperties": true,
                  "type": "object"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Lines"
          }
        },
        "type": "object",
        "required": [
          "has_upcoming"
        ],
        "title": "UpcomingInvoiceResponse",
        "description": "Upcoming invoice preview."
      },
      "UpdateBrandingRequest": {
        "properties": {
          "company_name": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 100
              },
              {
                "type": "null"
              }
            ],
            "title": "Company Name"
          },
          "primary_color": {
            "anyOf": [
              {
                "type": "string",
                "pattern": "^#[0-9A-Fa-f]{6}$"
              },
              {
                "type": "null"
              }
            ],
            "title": "Primary Color"
          },
          "support_email": {
            "anyOf": [
              {
                "type": "string",
                "format": "email"
              },
              {
                "type": "null"
              }
            ],
            "title": "Support Email"
          },
          "support_url": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Support Url"
          }
        },
        "type": "object",
        "title": "UpdateBrandingRequest",
        "description": "Request to update branding settings."
      },
      "UpdatePromptRequest": {
        "properties": {
          "current_prompt": {
            "type": "string",
            "maxLength": 50000,
            "minLength": 10,
            "title": "Current Prompt",
            "description": "The existing system prompt to modify"
          },
          "instruction": {
            "type": "string",
            "maxLength": 1000,
            "minLength": 3,
            "title": "Instruction",
            "description": "Instructions for how to modify the prompt"
          },
          "functions": {
            "items": {
              "$ref": "#/components/schemas/FunctionForUpdate"
            },
            "type": "array",
            "title": "Functions",
            "description": "Optional: custom functions to integrate into the prompt"
          },
          "quick_action": {
            "anyOf": [
              {
                "type": "string",
                "enum": [
                  "integrate_functions",
                  "condense"
                ]
              },
              {
                "type": "null"
              }
            ],
            "title": "Quick Action",
            "description": "Special action: 'integrate_functions' or 'condense'"
          }
        },
        "type": "object",
        "required": [
          "current_prompt",
          "instruction"
        ],
        "title": "UpdatePromptRequest",
        "description": "Request to update an existing system prompt using AI."
      },
      "UpdatePromptResponse": {
        "properties": {
          "original_prompt": {
            "type": "string",
            "title": "Original Prompt"
          },
          "updated_prompt": {
            "type": "string",
            "title": "Updated Prompt"
          },
          "changes_summary": {
            "type": "string",
            "title": "Changes Summary"
          },
          "changes_made": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Changes Made"
          }
        },
        "type": "object",
        "required": [
          "original_prompt",
          "updated_prompt",
          "changes_summary",
          "changes_made"
        ],
        "title": "UpdatePromptResponse",
        "description": "Response with the updated system prompt and changes summary."
      },
      "UpdateSubAccountRequest": {
        "properties": {
          "name": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 100,
                "minLength": 1
              },
              {
                "type": "null"
              }
            ],
            "title": "Name"
          },
          "admin_email": {
            "anyOf": [
              {
                "type": "string",
                "format": "email"
              },
              {
                "type": "null"
              }
            ],
            "title": "Admin Email"
          },
          "admin_name": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 100
              },
              {
                "type": "null"
              }
            ],
            "title": "Admin Name"
          },
          "per_minute_rate_cents": {
            "anyOf": [
              {
                "type": "integer",
                "maximum": 1000.0,
                "minimum": 0.0
              },
              {
                "type": "null"
              }
            ],
            "title": "Per Minute Rate Cents"
          },
          "monthly_platform_fee_cents": {
            "anyOf": [
              {
                "type": "integer",
                "minimum": 0.0
              },
              {
                "type": "null"
              }
            ],
            "title": "Monthly Platform Fee Cents"
          },
          "is_active": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Is Active"
          },
          "billing_start_day": {
            "anyOf": [
              {
                "type": "integer",
                "maximum": 28.0,
                "minimum": 1.0
              },
              {
                "type": "null"
              }
            ],
            "title": "Billing Start Day"
          },
          "upcharge_by_provider": {
            "anyOf": [
              {
                "additionalProperties": {
                  "type": "integer"
                },
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Upcharge By Provider"
          },
          "test_demo_upcharge_by_provider": {
            "anyOf": [
              {
                "additionalProperties": {
                  "type": "integer"
                },
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Test Demo Upcharge By Provider"
          },
          "text_upcharge_by_type": {
            "anyOf": [
              {
                "additionalProperties": {
                  "type": "integer"
                },
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Text Upcharge By Type"
          }
        },
        "type": "object",
        "title": "UpdateSubAccountRequest",
        "description": "Request to update a sub-account."
      },
      "UsageExportRecord": {
        "properties": {
          "id": {
            "type": "string",
            "title": "Id"
          },
          "sub_account_id": {
            "type": "string",
            "format": "uuid",
            "title": "Sub Account Id"
          },
          "sub_account_name": {
            "type": "string",
            "title": "Sub Account Name"
          },
          "sub_account_status": {
            "type": "string",
            "title": "Sub Account Status",
            "default": "active"
          },
          "call_log_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Call Log Id"
          },
          "date": {
            "type": "string",
            "format": "date-time",
            "title": "Date"
          },
          "time": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Time"
          },
          "direction": {
            "type": "string",
            "title": "Direction",
            "default": "inbound"
          },
          "minutes": {
            "type": "integer",
            "title": "Minutes"
          },
          "cost_cents": {
            "type": "integer",
            "title": "Cost Cents"
          },
          "revenue_cents": {
            "type": "integer",
            "title": "Revenue Cents"
          },
          "margin_cents": {
            "type": "integer",
            "title": "Margin Cents"
          },
          "voice_provider": {
            "type": "string",
            "title": "Voice Provider",
            "default": "xai"
          }
        },
        "type": "object",
        "required": [
          "id",
          "sub_account_id",
          "sub_account_name",
          "date",
          "minutes",
          "cost_cents",
          "revenue_cents",
          "margin_cents"
        ],
        "title": "UsageExportRecord",
        "description": "Single usage record for export - matches frontend AgencyUsageRecord."
      },
      "UsageExportResponse": {
        "properties": {
          "records": {
            "items": {
              "$ref": "#/components/schemas/UsageExportRecord"
            },
            "type": "array",
            "title": "Records"
          },
          "total": {
            "type": "integer",
            "title": "Total"
          },
          "summary": {
            "$ref": "#/components/schemas/UsageExportSummary"
          },
          "period_start": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Period Start"
          },
          "period_end": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Period End"
          },
          "period_source": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Period Source"
          }
        },
        "type": "object",
        "required": [
          "records",
          "total",
          "summary"
        ],
        "title": "UsageExportResponse",
        "description": "Usage export with records - matches frontend AgencyUsageResponse."
      },
      "UsageExportSummary": {
        "properties": {
          "total_calls": {
            "type": "integer",
            "title": "Total Calls"
          },
          "total_seconds": {
            "type": "integer",
            "title": "Total Seconds"
          },
          "total_cost_cents": {
            "type": "integer",
            "title": "Total Cost Cents"
          },
          "total_revenue_cents": {
            "type": "integer",
            "title": "Total Revenue Cents"
          },
          "total_margin_cents": {
            "type": "integer",
            "title": "Total Margin Cents"
          },
          "total_billable_minutes": {
            "type": "integer",
            "title": "Total Billable Minutes",
            "default": 0
          },
          "by_provider": {
            "items": {
              "$ref": "#/components/schemas/CostByProvider"
            },
            "type": "array",
            "title": "By Provider",
            "default": []
          },
          "by_direction": {
            "items": {
              "$ref": "#/components/schemas/CostByDirection"
            },
            "type": "array",
            "title": "By Direction",
            "default": []
          }
        },
        "type": "object",
        "required": [
          "total_calls",
          "total_seconds",
          "total_cost_cents",
          "total_revenue_cents",
          "total_margin_cents"
        ],
        "title": "UsageExportSummary",
        "description": "Summary stats for usage export."
      },
      "UsageListResponse": {
        "properties": {
          "usage_records": {
            "items": {
              "$ref": "#/components/schemas/UsageRecord"
            },
            "type": "array",
            "title": "Usage Records"
          },
          "total_count": {
            "type": "integer",
            "title": "Total Count"
          },
          "total_minutes": {
            "type": "number",
            "title": "Total Minutes"
          },
          "total_cost_cents": {
            "type": "integer",
            "title": "Total Cost Cents"
          },
          "text_messages_count": {
            "type": "integer",
            "title": "Text Messages Count",
            "default": 0
          },
          "text_messages_cost_cents": {
            "type": "integer",
            "title": "Text Messages Cost Cents",
            "default": 0
          }
        },
        "type": "object",
        "required": [
          "usage_records",
          "total_count",
          "total_minutes",
          "total_cost_cents"
        ],
        "title": "UsageListResponse",
        "description": "Response containing list of usage records."
      },
      "UsageRecord": {
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "title": "Id"
          },
          "call_log_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "title": "Call Log Id"
          },
          "minutes": {
            "type": "number",
            "title": "Minutes"
          },
          "rate_cents": {
            "type": "integer",
            "title": "Rate Cents"
          },
          "total_cents": {
            "type": "integer",
            "title": "Total Cents"
          },
          "synced_to_stripe": {
            "type": "boolean",
            "title": "Synced To Stripe"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "title": "Created At"
          }
        },
        "type": "object",
        "required": [
          "id",
          "minutes",
          "rate_cents",
          "total_cents",
          "synced_to_stripe",
          "created_at"
        ],
        "title": "UsageRecord",
        "description": "Individual usage record."
      },
      "UsageSummary": {
        "properties": {
          "current_period_start": {
            "type": "string",
            "format": "date-time",
            "title": "Current Period Start"
          },
          "current_period_end": {
            "type": "string",
            "format": "date-time",
            "title": "Current Period End"
          },
          "total_minutes": {
            "type": "integer",
            "title": "Total Minutes"
          },
          "total_cost_cents": {
            "type": "integer",
            "title": "Total Cost Cents"
          },
          "calls_count": {
            "type": "integer",
            "title": "Calls Count"
          },
          "text_messages_count": {
            "type": "integer",
            "title": "Text Messages Count",
            "default": 0
          },
          "text_messages_cost_cents": {
            "type": "integer",
            "title": "Text Messages Cost Cents",
            "default": 0
          }
        },
        "type": "object",
        "required": [
          "current_period_start",
          "current_period_end",
          "total_minutes",
          "total_cost_cents",
          "calls_count"
        ],
        "title": "UsageSummary",
        "description": "Summary of usage for the current billing period."
      },
      "UsageTimeseriesDay": {
        "properties": {
          "date": {
            "type": "string",
            "format": "date",
            "title": "Date"
          },
          "minutes": {
            "type": "number",
            "title": "Minutes"
          },
          "texts": {
            "type": "integer",
            "title": "Texts"
          },
          "amount_cents": {
            "type": "integer",
            "title": "Amount Cents"
          },
          "cumulative_minutes": {
            "type": "number",
            "title": "Cumulative Minutes"
          },
          "cumulative_amount_cents": {
            "type": "integer",
            "title": "Cumulative Amount Cents"
          },
          "is_future": {
            "type": "boolean",
            "title": "Is Future"
          }
        },
        "type": "object",
        "required": [
          "date",
          "minutes",
          "texts",
          "amount_cents",
          "cumulative_minutes",
          "cumulative_amount_cents",
          "is_future"
        ],
        "title": "UsageTimeseriesDay",
        "description": "One UTC day of a billing period. A running total, never a projection."
      },
      "UsageTimeseriesResponse": {
        "properties": {
          "period_start": {
            "type": "string",
            "format": "date-time",
            "title": "Period Start"
          },
          "period_end": {
            "type": "string",
            "format": "date-time",
            "title": "Period End"
          },
          "period_source": {
            "type": "string",
            "title": "Period Source"
          },
          "pricing": {
            "type": "string",
            "enum": [
              "wholesale",
              "client_price"
            ],
            "title": "Pricing"
          },
          "days": {
            "items": {
              "$ref": "#/components/schemas/UsageTimeseriesDay"
            },
            "type": "array",
            "title": "Days"
          }
        },
        "type": "object",
        "required": [
          "period_start",
          "period_end",
          "period_source",
          "pricing",
          "days"
        ],
        "title": "UsageTimeseriesResponse",
        "description": "Daily usage across the whole period, zero-filled, oldest day first.\n\npricing='wholesale': what Stripe bills the agency (agency screens).\npricing='client_price': what the tenant was charged (the agency's price\nfor a sub-account, the plan price for a direct customer)."
      },
      "UserResponse": {
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "title": "Id"
          },
          "email": {
            "type": "string",
            "title": "Email"
          },
          "full_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Full Name"
          },
          "role": {
            "type": "string",
            "title": "Role"
          },
          "tenant_id": {
            "type": "string",
            "format": "uuid",
            "title": "Tenant Id"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "title": "Created At"
          },
          "is_super_admin": {
            "type": "boolean",
            "title": "Is Super Admin",
            "default": false
          }
        },
        "type": "object",
        "required": [
          "id",
          "email",
          "role",
          "tenant_id",
          "created_at"
        ],
        "title": "UserResponse",
        "description": "User data response."
      },
      "ValidationError": {
        "properties": {
          "loc": {
            "items": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "integer"
                }
              ]
            },
            "type": "array",
            "title": "Location"
          },
          "msg": {
            "type": "string",
            "title": "Message"
          },
          "type": {
            "type": "string",
            "title": "Error Type"
          },
          "input": {
            "title": "Input"
          },
          "ctx": {
            "type": "object",
            "title": "Context"
          }
        },
        "type": "object",
        "required": [
          "loc",
          "msg",
          "type"
        ],
        "title": "ValidationError"
      },
      "VariableDefinition": {
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 50,
            "minLength": 1,
            "pattern": "^[\\w-]+$",
            "title": "Name",
            "description": "Variable name (alphanumeric, underscore, hyphen)"
          },
          "description": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 200
              },
              {
                "type": "null"
              }
            ],
            "title": "Description",
            "description": "Description of what this variable represents"
          },
          "required": {
            "type": "boolean",
            "title": "Required",
            "description": "Whether this variable must be provided at call time",
            "default": false
          },
          "default_value": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 500
              },
              {
                "type": "null"
              }
            ],
            "title": "Default Value",
            "description": "Default value if not provided (only for non-required)"
          }
        },
        "type": "object",
        "required": [
          "name"
        ],
        "title": "VariableDefinition",
        "description": "Definition for a template variable in agent prompts."
      },
      "VoicemailChoice": {
        "properties": {
          "id": {
            "type": "string",
            "title": "Id"
          },
          "name": {
            "type": "string",
            "title": "Name"
          }
        },
        "type": "object",
        "required": [
          "id",
          "name"
        ],
        "title": "VoicemailChoice"
      },
      "VoicemailOptionsResponse": {
        "properties": {
          "provider": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Provider",
            "description": "drop_cowboy, slybroadcast, or null when none is connected"
          },
          "pools": {
            "items": {
              "$ref": "#/components/schemas/VoicemailPool"
            },
            "type": "array",
            "title": "Pools"
          },
          "recordings": {
            "items": {
              "$ref": "#/components/schemas/VoicemailChoice"
            },
            "type": "array",
            "title": "Recordings"
          },
          "voices": {
            "items": {
              "$ref": "#/components/schemas/VoicemailChoice"
            },
            "type": "array",
            "title": "Voices"
          },
          "pool_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Pool Id",
            "description": "Caller number pool saved in Settings"
          },
          "voice_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Voice Id",
            "description": "Default voice saved in Settings"
          },
          "error": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Error",
            "description": "Plain reason the lists could not load"
          }
        },
        "type": "object",
        "title": "VoicemailOptionsResponse",
        "description": "Choices for voicemail steps and Settings (DAN-167 S-18)."
      },
      "VoicemailPool": {
        "properties": {
          "id": {
            "type": "string",
            "title": "Id"
          },
          "name": {
            "type": "string",
            "title": "Name"
          },
          "number_count": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Number Count"
          }
        },
        "type": "object",
        "required": [
          "id",
          "name"
        ],
        "title": "VoicemailPool"
      },
      "WebCrawlerCreate": {
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 200,
            "minLength": 1,
            "title": "Name"
          },
          "root_url": {
            "type": "string",
            "minLength": 1,
            "title": "Root Url",
            "description": "URL to crawl"
          },
          "schedule_interval": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Schedule Interval",
            "description": "Recrawl interval: 'daily', 'weekly', 'monthly', or None"
          }
        },
        "type": "object",
        "required": [
          "name",
          "root_url"
        ],
        "title": "WebCrawlerCreate",
        "description": "Request body for creating a web crawler source."
      },
      "WebCrawlerResponse": {
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "title": "Id"
          },
          "collection_id": {
            "type": "string",
            "format": "uuid",
            "title": "Collection Id"
          },
          "name": {
            "type": "string",
            "title": "Name"
          },
          "source_type": {
            "type": "string",
            "title": "Source Type",
            "default": "web_crawler"
          },
          "root_url": {
            "type": "string",
            "title": "Root Url"
          },
          "schedule_interval": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Schedule Interval"
          },
          "crawl_status": {
            "type": "string",
            "title": "Crawl Status",
            "default": "pending"
          },
          "pages_found": {
            "type": "integer",
            "title": "Pages Found",
            "default": 0
          },
          "last_crawled_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Last Crawled At"
          },
          "next_crawl_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Next Crawl At"
          },
          "error_message": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Error Message"
          },
          "document_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "title": "Document Id"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "title": "Created At"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "title": "Updated At"
          }
        },
        "type": "object",
        "required": [
          "id",
          "collection_id",
          "name",
          "root_url",
          "created_at",
          "updated_at"
        ],
        "title": "WebCrawlerResponse",
        "description": "Web crawler source response."
      },
      "WebCrawlerScheduleUpdate": {
        "properties": {
          "schedule_interval": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Schedule Interval",
            "description": "Recrawl interval: 'daily', 'weekly', 'monthly', or None"
          }
        },
        "type": "object",
        "title": "WebCrawlerScheduleUpdate",
        "description": "Update the recrawl schedule for a web crawler."
      },
      "WebhookSettingsResponse": {
        "properties": {
          "webhook_url": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Webhook Url"
          },
          "webhook_secret": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Webhook Secret"
          },
          "webhook_enabled": {
            "type": "boolean",
            "title": "Webhook Enabled",
            "default": false
          },
          "ghl_conversation_sync_enabled": {
            "type": "boolean",
            "title": "Ghl Conversation Sync Enabled",
            "default": false
          }
        },
        "type": "object",
        "title": "WebhookSettingsResponse",
        "description": "Response for webhook settings."
      },
      "WebhookTestContact": {
        "properties": {
          "id": {
            "type": "string",
            "title": "Id"
          },
          "first_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "First Name"
          },
          "last_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Last Name"
          },
          "email": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Email"
          },
          "phone": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Phone"
          },
          "company": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Company"
          },
          "tags": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Tags",
            "default": []
          }
        },
        "type": "object",
        "required": [
          "id"
        ],
        "title": "WebhookTestContact",
        "description": "A GHL contact selected by the user to populate the test payload."
      },
      "WebhookTestField": {
        "properties": {
          "name": {
            "type": "string",
            "title": "Name"
          },
          "type": {
            "type": "string",
            "title": "Type"
          },
          "enum_values": {
            "anyOf": [
              {
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Enum Values"
          }
        },
        "type": "object",
        "required": [
          "name",
          "type"
        ],
        "title": "WebhookTestField",
        "description": "A single field definition for webhook test payload generation."
      },
      "WebhookTestRequest": {
        "properties": {
          "webhook_url": {
            "type": "string",
            "maxLength": 2000,
            "minLength": 10,
            "title": "Webhook Url",
            "description": "Webhook URL to test"
          },
          "webhook_method": {
            "type": "string",
            "title": "Webhook Method",
            "description": "HTTP method for webhook call",
            "default": "POST"
          },
          "webhook_headers": {
            "additionalProperties": {
              "type": "string"
            },
            "type": "object",
            "title": "Webhook Headers",
            "description": "Custom headers to include in webhook request"
          },
          "webhook_timeout_ms": {
            "type": "integer",
            "maximum": 30000.0,
            "minimum": 1000.0,
            "title": "Webhook Timeout Ms",
            "description": "Timeout for webhook call in milliseconds",
            "default": 5000
          },
          "function_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Function Name",
            "description": "Function name to include in test payload"
          },
          "fields": {
            "anyOf": [
              {
                "items": {
                  "$ref": "#/components/schemas/WebhookTestField"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Fields",
            "description": "Configured fields to build sample arguments from"
          },
          "contact": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/WebhookTestContact"
              },
              {
                "type": "null"
              }
            ],
            "description": "GHL contact to populate call_context with real data"
          }
        },
        "type": "object",
        "required": [
          "webhook_url"
        ],
        "title": "WebhookTestRequest",
        "description": "Request body for testing a webhook URL before creating a function."
      },
      "WebhookUrlTestRequest": {
        "properties": {
          "webhook_url": {
            "type": "string",
            "title": "Webhook Url"
          },
          "form_fields": {
            "anyOf": [
              {
                "items": {
                  "additionalProperties": true,
                  "type": "object"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Form Fields"
          }
        },
        "type": "object",
        "required": [
          "webhook_url"
        ],
        "title": "WebhookUrlTestRequest",
        "description": "Request to test a webhook URL directly (no demo ID needed)."
      },
      "app__agents__prompt_router__GenerateAllKnowledgeRequest": {
        "properties": {
          "business_name": {
            "type": "string",
            "maxLength": 100,
            "minLength": 1,
            "title": "Business Name"
          },
          "industry": {
            "type": "string",
            "maxLength": 50,
            "minLength": 1,
            "title": "Industry"
          },
          "description": {
            "type": "string",
            "maxLength": 500,
            "title": "Description",
            "description": "Business description for context",
            "default": ""
          },
          "agent_mode": {
            "type": "string",
            "pattern": "^(inbound|outbound|both)$",
            "title": "Agent Mode",
            "description": "Agent mode \u2014 outbound routes 'team' to objections generator",
            "default": "inbound"
          }
        },
        "type": "object",
        "required": [
          "business_name",
          "industry"
        ],
        "title": "GenerateAllKnowledgeRequest",
        "description": "Request to generate all knowledge sections at once."
      },
      "app__agents__prompt_router__GenerateKnowledgeRequest": {
        "properties": {
          "business_name": {
            "type": "string",
            "maxLength": 100,
            "minLength": 1,
            "title": "Business Name"
          },
          "industry": {
            "type": "string",
            "maxLength": 50,
            "minLength": 1,
            "title": "Industry"
          },
          "section": {
            "type": "string",
            "title": "Section",
            "description": "Section to generate: services, pricing, team, or faqs"
          },
          "description": {
            "type": "string",
            "maxLength": 500,
            "title": "Description",
            "description": "Business description for context",
            "default": ""
          },
          "services": {
            "type": "string",
            "maxLength": 2000,
            "title": "Services",
            "description": "Existing services list (for pricing/faqs context)",
            "default": ""
          },
          "agent_mode": {
            "type": "string",
            "pattern": "^(inbound|outbound|both)$",
            "title": "Agent Mode",
            "description": "Agent mode \u2014 outbound routes 'team' to objections generator",
            "default": "inbound"
          }
        },
        "type": "object",
        "required": [
          "business_name",
          "industry",
          "section"
        ],
        "title": "GenerateKnowledgeRequest",
        "description": "Request to generate a knowledge section using AI."
      },
      "app__text_assistant__prompt_router__GenerateAllKnowledgeRequest": {
        "properties": {
          "business_name": {
            "type": "string",
            "maxLength": 100,
            "minLength": 1,
            "title": "Business Name"
          },
          "industry": {
            "type": "string",
            "maxLength": 50,
            "minLength": 1,
            "title": "Industry"
          },
          "description": {
            "type": "string",
            "maxLength": 500,
            "title": "Description",
            "description": "Business description for context",
            "default": ""
          }
        },
        "type": "object",
        "required": [
          "business_name",
          "industry"
        ],
        "title": "GenerateAllKnowledgeRequest",
        "description": "Request to generate all knowledge sections at once."
      },
      "app__text_assistant__prompt_router__GenerateKnowledgeRequest": {
        "properties": {
          "business_name": {
            "type": "string",
            "maxLength": 100,
            "minLength": 1,
            "title": "Business Name"
          },
          "industry": {
            "type": "string",
            "maxLength": 50,
            "minLength": 1,
            "title": "Industry"
          },
          "section": {
            "type": "string",
            "title": "Section",
            "description": "Section to generate: services, pricing, team, or faqs"
          },
          "description": {
            "type": "string",
            "maxLength": 500,
            "title": "Description",
            "description": "Business description for context",
            "default": ""
          },
          "services": {
            "type": "string",
            "maxLength": 2000,
            "title": "Services",
            "description": "Existing services list (for pricing/faqs context)",
            "default": ""
          }
        },
        "type": "object",
        "required": [
          "business_name",
          "industry",
          "section"
        ],
        "title": "GenerateKnowledgeRequest",
        "description": "Request to generate a knowledge section using AI."
      }
    },
    "securitySchemes": {
      "APIKeyHeader": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key"
      }
    }
  },
  "servers": [
    {
      "url": "https://leadlock-app.onrender.com",
      "description": "Leadlock API"
    }
  ]
}