{
  "openapi": "3.0.0",
  "info": {
    "title": "DialNexa API",
    "description": "Public `/v1` REST API for the DialNexa voice AI platform.",
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "https://api.dialnexa.com",
      "description": "DialNexa production API"
    }
  ],
  "security": [
    {
      "bearer": []
    }
  ],
  "tags": [
    {
      "name": "Agents"
    },
    {
      "name": "Batch Calls"
    },
    {
      "name": "Calls"
    },
    {
      "name": "Knowledge Base"
    },
    {
      "name": "Languages"
    },
    {
      "name": "LLMs"
    },
    {
      "name": "Phone Numbers"
    },
    {
      "name": "Organization Folders"
    },
    {
      "name": "Transcribers"
    },
    {
      "name": "Webhooks"
    },
    {
      "name": "Voices"
    },
    {
      "name": "Workflows"
    },
    {
      "name": "Workflow Leads"
    },
    {
      "name": "Authentication"
    },
    {
      "name": "Agent Builder"
    },
    {
      "name": "Agent Evaluations"
    }
  ],
  "paths": {
    "/v1/agents": {
      "post": {
        "description": "Creates an agent with its first draft version. Optionally include `agent_functions` and `post_call_analysis` in the body to set them at creation time.\n\n**Phone numbers** are linked to the agent, not to a version. Once the agent has a published version, attach numbers with `POST /v1/agents/{agentId}/phone-numbers`.",
        "operationId": "createAgent",
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateAgentRequest"
              },
              "examples": {
                "request": {
                  "summary": "Create an agent",
                  "value": {
                    "title": "Customer Support Agent",
                    "language_id": "lang_en_in",
                    "voice_id": "voice_abc123",
                    "llm_id": "llm_A1B2C3D4E5F6G7",
                    "transcriber_id": "trs_deepgram_nova_2",
                    "system_prompt_text": "You are a helpful support agent. Confirm the customer issue and summarize next steps.",
                    "fallback_stt_enabled": true,
                    "stt_fallback_transcriber_id": "trs_soniox",
                    "post_call_analysis": [
                      {
                        "field_name": "issue_type",
                        "field_type": "TEXT",
                        "field_description": "Main customer issue discussed on the call"
                      }
                    ],
                    "agent_type": "Single_Prompt_Agent",
                    "prompt_text": "You are a helpful support agent. Confirm the customer's issue and summarize next steps."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Agent created successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "error",
                    "statusCode",
                    "message",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "statusCode": {
                      "type": "integer",
                      "example": 201
                    },
                    "message": {
                      "type": "string",
                      "example": "Success"
                    },
                    "data": {
                      "$ref": "#/components/schemas/Agents"
                    },
                    "timestamp": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                },
                "examples": {
                  "success": {
                    "summary": "Successful response",
                    "value": {
                      "success": true,
                      "error": false,
                      "statusCode": 201,
                      "message": "Success",
                      "data": {
                        "id": "agent_2g7Xy3tY53gRlp",
                        "folder_id": null,
                        "current_version_number": "0",
                        "timezone": null,
                        "agent_type": "Single_Prompt_Agent",
                        "pipeline_type": "Cascaded",
                        "webhook_id": null,
                        "current_version": {
                          "agent_id": "agent_2g7Xy3tY53gRlp",
                          "version_number": "0",
                          "version_title": "Version 0",
                          "title": "Customer Support Agent",
                          "is_published": false,
                          "language_id": "lang_en_in",
                          "voice_id": "voice_abc123",
                          "llm_id": "llm_A1B2C3D4E5F6G7",
                          "transcriber_id": "trs_deepgram_nova_2",
                          "fallback_stt_enabled": true,
                          "stt_fallback_transcriber_id": "trs_soniox"
                        },
                        "versions": [
                          {
                            "agent_id": "agent_2g7Xy3tY53gRlp",
                            "version_number": "0",
                            "version_title": "Version 0",
                            "title": "Customer Support Agent",
                            "is_published": false,
                            "language_id": "lang_en_in",
                            "voice_id": "voice_abc123",
                            "llm_id": "llm_A1B2C3D4E5F6G7",
                            "transcriber_id": "trs_deepgram_nova_2",
                            "fallback_stt_enabled": true,
                            "stt_fallback_transcriber_id": "trs_soniox"
                          }
                        ],
                        "inbound_phone_numbers": [],
                        "outbound_phone_numbers": []
                      },
                      "timestamp": "2026-09-07T06:00:00.000Z"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request body.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "400 Bad Request",
                    "value": {
                      "statusCode": 400,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "title must be shorter than or equal to 70 characters",
                      "errors": [
                        "title must be shorter than or equal to 70 characters"
                      ]
                    }
                  },
                  "s2sLanguages": {
                    "summary": "Speech-to-Speech agent with secondary languages on a non-Gemini model",
                    "value": {
                      "statusCode": 400,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Speech-to-Speech agents that speak more than one language run on Gemini Live. Pick a Gemini model or remove the secondary languages.",
                      "errors": [
                        "Speech-to-Speech agents that speak more than one language run on Gemini Live. Pick a Gemini model or remove the secondary languages."
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "401 Unauthorized",
                    "value": {
                      "statusCode": 401,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Invalid API key",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "The request turns off a setting only DialNexa can disable (audio_cache_enabled or predictive_preprocessing_enabled set to false).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "403 Forbidden",
                    "value": {
                      "statusCode": 403,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Only super admins can disable audio cache. Please contact Dialnexa for disabling it.",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "500 Internal Server Error",
                    "value": {
                      "statusCode": 500,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Failed to create agent: Internal server error",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "A referenced resource was not found: the voice, the voice model, or a fallback voice from another workspace.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Two agent_functions items have the same display name.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "Duplicate function name",
                    "value": {
                      "statusCode": 409,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Agent function with display name \"book_meeting\" already exists for this agent version",
                      "errors": []
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "summary": "Create Agent",
        "tags": [
          "Agents"
        ]
      },
      "get": {
        "description": "Returns every agent in your organization with all versions. Agent functions and phone numbers are not included: fetch one agent by ID for them.",
        "operationId": "listAgents",
        "parameters": [],
        "responses": {
          "200": {
            "description": "Agents returned successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "error",
                    "statusCode",
                    "message",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "statusCode": {
                      "type": "integer",
                      "example": 200
                    },
                    "message": {
                      "type": "string",
                      "example": "Success"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "agents": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/AgentRecord"
                          }
                        }
                      }
                    },
                    "timestamp": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                },
                "examples": {
                  "success": {
                    "summary": "Successful response",
                    "value": {
                      "success": true,
                      "error": false,
                      "statusCode": 200,
                      "message": "Success",
                      "data": {
                        "agents": [
                          {
                            "id": "agent_2g7Xy3tY53gRlp",
                            "folder_id": null,
                            "current_version_number": "0",
                            "timezone": "Asia/Kolkata",
                            "agent_type": "Single_Prompt_Agent",
                            "pipeline_type": "Cascaded",
                            "webhook_id": null,
                            "current_version": {
                              "agent_id": "agent_2g7Xy3tY53gRlp",
                              "version_number": "0",
                              "version_title": "Version 0",
                              "title": "Customer Support Agent",
                              "is_published": false,
                              "language_id": "lang_en_in",
                              "voice_id": "voice_abc123",
                              "llm_id": "llm_A1B2C3D4E5F6G7",
                              "transcriber_id": "trs_deepgram_nova_2",
                              "fallback_stt_enabled": true,
                              "stt_fallback_transcriber_id": "trs_soniox"
                            },
                            "versions": [
                              {
                                "agent_id": "agent_2g7Xy3tY53gRlp",
                                "version_number": "0",
                                "version_title": "Version 0",
                                "title": "Customer Support Agent",
                                "is_published": false,
                                "language_id": "lang_en_in",
                                "voice_id": "voice_abc123",
                                "llm_id": "llm_A1B2C3D4E5F6G7",
                                "transcriber_id": "trs_deepgram_nova_2",
                                "fallback_stt_enabled": true,
                                "stt_fallback_transcriber_id": "trs_soniox"
                              }
                            ]
                          }
                        ]
                      },
                      "timestamp": "2026-09-07T06:00:00.000Z"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "401 Unauthorized",
                    "value": {
                      "statusCode": 401,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Invalid API key",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "500 Internal Server Error",
                    "value": {
                      "statusCode": 500,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Failed to fetch all agents: Internal server error",
                      "errors": []
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "summary": "List Agents",
        "tags": [
          "Agents"
        ]
      }
    },
    "/v1/agents/{id}": {
      "patch": {
        "description": "Updates the specified draft version of an agent. `version_number` is required.\n\n**Managing functions via this endpoint:**\n- Pass `agent_functions: [...]` to replace the version's functions. The platform `end_call` function is always kept.\n- Pass `agent_functions: []` to remove every function except `end_call`.\n- Omit `agent_functions` entirely to leave existing functions untouched.\n\n**Post-call analysis LLM:**\n- Pass `post_call_analysis_llm_id`, for example `llm_A1B2C3D4E5F6G7`, to set the LLM used for post-call field extraction.\n- Pass `null` to clear it so the workspace default is used.\n- Omit the field to leave it unchanged.\n- It is stored on the version's existing post-call fields: it has no effect when there are none, a replaced `post_call_analysis` list gets new fields without it, and it is saved before the rest of the request is validated, so a rejected request can still have changed it.\n\n**Phone numbers** are linked to the agent, not to a version. Manage them with `/v1/agents/{agentId}/phone-numbers`. Every version uses the agent's numbers, and inbound calls run on the latest published version.\n\n**While a batch is running on this agent**, the request returns `409 Conflict` with code `AGENT_HAS_RUNNING_BATCH` when it would change a published version in place (runtime fields; `version_title` and `folder_id` can still change) or change `timezone` or `pipeline_type`. Drafts stay editable and can be published. The running batch keeps dialing the version it was created with.\n\nA published version cannot be edited. Runtime changes are blocked while a batch runs on the agent; edit and publish a new draft instead.\n\nNull is ignored for `end_call_on_hold_sec`, `language_default_message`, `version_title`, `reminder_message_content`, `llm_fallback_model` and `llm_fallback_delay_ms`: the stored value is kept.",
        "operationId": "updateAgent",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "description": "Agent ID",
            "schema": {
              "example": "agent_2g7Xy3tY53gRlp",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateAgentRequest"
              },
              "examples": {
                "request": {
                  "summary": "Update a draft agent version",
                  "value": {
                    "version_number": 0,
                    "title": "Customer Support Agent",
                    "llm_id": "llm_A1B2C3D4E5F6G7",
                    "fallback_stt_enabled": true,
                    "stt_fallback_transcriber_id": "trs_soniox",
                    "post_call_analysis_llm_id": "llm_A1B2C3D4E5F6G7"
                  }
                },
                "clearPostCallAnalysisLlm": {
                  "summary": "Clear post-call analysis LLM override",
                  "value": {
                    "version_number": 0,
                    "post_call_analysis_llm_id": null
                  }
                },
                "publishDraft": {
                  "summary": "Publish a draft version",
                  "value": {
                    "version_number": 2,
                    "is_published": true
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Agent updated successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "error",
                    "statusCode",
                    "message",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "statusCode": {
                      "type": "integer",
                      "example": 200
                    },
                    "message": {
                      "type": "string",
                      "example": "Success"
                    },
                    "data": {
                      "$ref": "#/components/schemas/Agents"
                    },
                    "timestamp": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                },
                "examples": {
                  "success": {
                    "summary": "Successful response",
                    "value": {
                      "success": true,
                      "error": false,
                      "statusCode": 200,
                      "message": "Success",
                      "data": {
                        "id": "agent_2g7Xy3tY53gRlp",
                        "folder_id": null,
                        "current_version_number": "0",
                        "timezone": "Asia/Kolkata",
                        "agent_type": "Single_Prompt_Agent",
                        "pipeline_type": "Cascaded",
                        "webhook_id": null,
                        "current_version": {
                          "agent_id": "agent_2g7Xy3tY53gRlp",
                          "version_number": "0",
                          "version_title": "Version 0",
                          "title": "Customer Support Agent",
                          "is_published": false,
                          "language_id": "lang_en_in",
                          "voice_id": "voice_abc123",
                          "llm_id": "llm_A1B2C3D4E5F6G7",
                          "transcriber_id": "trs_deepgram_nova_2",
                          "fallback_stt_enabled": true,
                          "stt_fallback_transcriber_id": "trs_soniox"
                        },
                        "versions": [
                          {
                            "agent_id": "agent_2g7Xy3tY53gRlp",
                            "version_number": "0",
                            "version_title": "Version 0",
                            "title": "Customer Support Agent",
                            "is_published": false,
                            "language_id": "lang_en_in",
                            "voice_id": "voice_abc123",
                            "llm_id": "llm_A1B2C3D4E5F6G7",
                            "transcriber_id": "trs_deepgram_nova_2",
                            "fallback_stt_enabled": true,
                            "stt_fallback_transcriber_id": "trs_soniox"
                          }
                        ],
                        "inbound_phone_numbers": [],
                        "outbound_phone_numbers": [
                          {
                            "id": "phn_abc123",
                            "phone_number": "9876543210",
                            "country_iso": "91",
                            "nickname": "Support line",
                            "sip_trunk_enabled": false,
                            "linked_at": "2026-09-30T06:00:00.000Z"
                          }
                        ]
                      },
                      "timestamp": "2026-09-07T06:00:00.000Z"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid body, incompatible configuration, or, when publishing, a prompt over the size limit for the selected model.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "400 Bad Request",
                    "value": {
                      "statusCode": 400,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "version_number must be a number conforming to the specified constraints",
                      "errors": [
                        "version_number must be a number conforming to the specified constraints"
                      ]
                    }
                  },
                  "s2sLanguages": {
                    "summary": "Speech-to-Speech agent with secondary languages on a non-Gemini model",
                    "value": {
                      "statusCode": 400,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Speech-to-Speech agents that speak more than one language run on Gemini Live. Pick a Gemini model or remove the secondary languages.",
                      "errors": [
                        "Speech-to-Speech agents that speak more than one language run on Gemini Live. Pick a Gemini model or remove the secondary languages."
                      ]
                    }
                  },
                  "llmRetired": {
                    "summary": "Publishing a version that uses a retired LLM",
                    "value": {
                      "statusCode": 400,
                      "error": true,
                      "success": false,
                      "data": {
                        "code": "LLM_RETIRED",
                        "llm_ids": [
                          "meqtu4wiqv5haq"
                        ]
                      },
                      "message": "This agent version uses GPT-4.1 Nano, which has been retired. Switch to a supported model and publish a new version.",
                      "errors": [
                        "This agent version uses GPT-4.1 Nano, which has been retired. Switch to a supported model and publish a new version."
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "401 Unauthorized",
                    "value": {
                      "statusCode": 401,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Invalid API key",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "The version is already published, or the request turns off a setting only DialNexa can disable (audio_cache_enabled or predictive_preprocessing_enabled set to false).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "403 Forbidden",
                    "value": {
                      "statusCode": 403,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "You cannot patch an already published agent version.",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Agent or version not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "404 Not Found",
                    "value": {
                      "statusCode": 404,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Agent with ID 2g7Xy3tY53gRlp not found",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "500 Internal Server Error",
                    "value": {
                      "statusCode": 500,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Failed to update agent: Internal server error",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "A batch is running on this agent and the request would change what it dials with.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CodedErrorResponse"
                },
                "examples": {
                  "agentHasRunningBatch": {
                    "summary": "409 Conflict",
                    "value": {
                      "statusCode": 409,
                      "error": true,
                      "success": false,
                      "data": {
                        "code": "AGENT_HAS_RUNNING_BATCH",
                        "batches": [
                          {
                            "id": "batch_abc123",
                            "title": "September renewals",
                            "status": "running"
                          }
                        ]
                      },
                      "message": "Batch \"September renewals\" is running on this agent. Pause it or wait for it to finish, or publish a new version instead.",
                      "errors": []
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "summary": "Update Agent",
        "tags": [
          "Agents"
        ]
      },
      "delete": {
        "description": "Deletes an agent and all its versions. Historical call records remain available.",
        "operationId": "deleteAgent",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "description": "Agent ID",
            "schema": {
              "example": "agent_2g7Xy3tY53gRlp",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Agent deleted successfully.",
            "content": {
              "application/json": {
                "examples": {
                  "success": {
                    "summary": "Successful response",
                    "value": {
                      "success": true,
                      "error": false,
                      "statusCode": 200,
                      "message": "Success",
                      "timestamp": "2026-09-07T06:00:00.000Z"
                    }
                  }
                },
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "error",
                    "statusCode",
                    "message",
                    "timestamp"
                  ],
                  "description": "The standard envelope without a data member.",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "statusCode": {
                      "type": "integer",
                      "example": 200
                    },
                    "message": {
                      "type": "string",
                      "example": "Success"
                    },
                    "timestamp": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "401 Unauthorized",
                    "value": {
                      "statusCode": 401,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Invalid API key",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Agent not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "404 Not Found",
                    "value": {
                      "statusCode": 404,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Agent with ID 2g7Xy3tY53gRlp not found",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "500 Internal Server Error",
                    "value": {
                      "statusCode": 500,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Failed to delete agent: Internal server error",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict: the agent is used by active workflows (AGENT_USED_IN_ACTIVE_WORKFLOWS, with affected_workflows in data), or one of its numbers cannot be released yet (PHONE_NUMBER_HAS_LIVE_CALLS, NUMBER_USED_BY_BATCH, or PHONE_NUMBER_USED_IN_ACTIVE_WORKFLOWS). Resolve what data lists, then retry.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "agentInActiveWorkflows": {
                    "summary": "409 Conflict",
                    "value": {
                      "statusCode": 409,
                      "error": true,
                      "success": false,
                      "data": {
                        "code": "AGENT_USED_IN_ACTIVE_WORKFLOWS",
                        "affected_workflows": [
                          {
                            "id": "Xy7Kp2mQ9rT4vB",
                            "title": "Lead follow-up",
                            "status": "active"
                          }
                        ]
                      },
                      "message": "This agent is used in 1 active workflow(s). Deactivate those workflows first, then retry.",
                      "errors": []
                    }
                  },
                  "usedByBatch": {
                    "summary": "409 Conflict",
                    "value": {
                      "statusCode": 409,
                      "error": true,
                      "success": false,
                      "data": {
                        "code": "NUMBER_USED_BY_BATCH",
                        "batches": [
                          {
                            "id": "batch_abc123",
                            "title": "September renewals",
                            "status": "paused"
                          }
                        ],
                        "live_calls": 0
                      },
                      "message": "1 unfinished batch(es) (\"September renewals\") and 0 live call(s) use this number. Change the batches' number or cancel them first.",
                      "errors": []
                    }
                  },
                  "liveCalls": {
                    "summary": "409 Conflict",
                    "value": {
                      "statusCode": 409,
                      "error": true,
                      "success": false,
                      "data": {
                        "code": "PHONE_NUMBER_HAS_LIVE_CALLS",
                        "live_calls": 2,
                        "batches": []
                      },
                      "message": "2 call(s) are in progress on this number. Wait for them to finish, then retry.",
                      "errors": []
                    }
                  },
                  "activeWorkflows": {
                    "summary": "409 Conflict",
                    "value": {
                      "statusCode": 409,
                      "error": true,
                      "success": false,
                      "data": {
                        "code": "PHONE_NUMBER_USED_IN_ACTIVE_WORKFLOWS",
                        "affected_workflows": [
                          {
                            "id": "Xy7Kp2mQ9rT4vB",
                            "title": "Lead follow-up",
                            "status": "active"
                          }
                        ]
                      },
                      "message": "This phone number is used in 1 active workflow(s). Pause those workflows first, then retry.",
                      "errors": []
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "summary": "Delete Agent",
        "tags": [
          "Agents"
        ]
      },
      "get": {
        "description": "Returns the agent with all versions. Each version includes `agent_functions`, `pronunciations`, and `postcall_analysis` embedded.",
        "operationId": "getAgent",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "description": "Agent ID",
            "schema": {
              "example": "agent_2g7Xy3tY53gRlp",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Agent returned with all versions and embedded agent_functions.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "error",
                    "statusCode",
                    "message",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "statusCode": {
                      "type": "integer",
                      "example": 200
                    },
                    "message": {
                      "type": "string",
                      "example": "Success"
                    },
                    "data": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/AgentRecord"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "inbound_phone_numbers": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "example": "phn_abc123"
                                  },
                                  "phone_number": {
                                    "type": "string",
                                    "example": "9876543210",
                                    "description": "The number without its country calling code."
                                  },
                                  "country_iso": {
                                    "type": "string",
                                    "example": "91",
                                    "description": "Country calling code."
                                  },
                                  "nickname": {
                                    "type": "string",
                                    "nullable": true,
                                    "description": "Label set in the dashboard."
                                  },
                                  "sip_trunk_enabled": {
                                    "type": "boolean"
                                  },
                                  "linked_at": {
                                    "type": "string",
                                    "format": "date-time",
                                    "nullable": true,
                                    "description": "When the number was linked to the agent, when known."
                                  }
                                },
                                "required": [
                                  "id",
                                  "phone_number",
                                  "country_iso",
                                  "nickname",
                                  "sip_trunk_enabled",
                                  "linked_at"
                                ]
                              },
                              "description": "Numbers that ring this agent. Up to 3."
                            },
                            "outbound_phone_numbers": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "example": "phn_abc123"
                                  },
                                  "phone_number": {
                                    "type": "string",
                                    "example": "9876543210",
                                    "description": "The number without its country calling code."
                                  },
                                  "country_iso": {
                                    "type": "string",
                                    "example": "91",
                                    "description": "Country calling code."
                                  },
                                  "nickname": {
                                    "type": "string",
                                    "nullable": true,
                                    "description": "Label set in the dashboard."
                                  },
                                  "sip_trunk_enabled": {
                                    "type": "boolean"
                                  },
                                  "linked_at": {
                                    "type": "string",
                                    "format": "date-time",
                                    "nullable": true,
                                    "description": "When the number was linked to the agent, when known."
                                  }
                                },
                                "required": [
                                  "id",
                                  "phone_number",
                                  "country_iso",
                                  "nickname",
                                  "sip_trunk_enabled",
                                  "linked_at"
                                ]
                              },
                              "description": "Numbers the agent can call from. Up to 3."
                            }
                          }
                        }
                      ]
                    },
                    "timestamp": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                },
                "examples": {
                  "success": {
                    "summary": "Successful response",
                    "value": {
                      "success": true,
                      "error": false,
                      "statusCode": 200,
                      "message": "Success",
                      "data": {
                        "id": "agent_2g7Xy3tY53gRlp",
                        "folder_id": null,
                        "current_version_number": "0",
                        "timezone": "Asia/Kolkata",
                        "agent_type": "Single_Prompt_Agent",
                        "pipeline_type": "Cascaded",
                        "webhook_id": null,
                        "current_version": {
                          "agent_id": "agent_2g7Xy3tY53gRlp",
                          "version_number": "0",
                          "version_title": "Version 0",
                          "title": "Customer Support Agent",
                          "is_published": false,
                          "language_id": "lang_en_in",
                          "voice_id": "voice_abc123",
                          "llm_id": "llm_A1B2C3D4E5F6G7",
                          "transcriber_id": "trs_deepgram_nova_2",
                          "fallback_stt_enabled": true,
                          "stt_fallback_transcriber_id": "trs_soniox"
                        },
                        "versions": [
                          {
                            "agent_id": "agent_2g7Xy3tY53gRlp",
                            "version_number": "0",
                            "version_title": "Version 0",
                            "title": "Customer Support Agent",
                            "is_published": false,
                            "language_id": "lang_en_in",
                            "voice_id": "voice_abc123",
                            "llm_id": "llm_A1B2C3D4E5F6G7",
                            "transcriber_id": "trs_deepgram_nova_2",
                            "fallback_stt_enabled": true,
                            "stt_fallback_transcriber_id": "trs_soniox"
                          }
                        ],
                        "inbound_phone_numbers": [],
                        "outbound_phone_numbers": [
                          {
                            "id": "phn_abc123",
                            "phone_number": "9876543210",
                            "country_iso": "91",
                            "nickname": "Support line",
                            "sip_trunk_enabled": false,
                            "linked_at": "2026-09-30T06:00:00.000Z"
                          }
                        ]
                      },
                      "timestamp": "2026-09-07T06:00:00.000Z"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "401 Unauthorized",
                    "value": {
                      "statusCode": 401,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Invalid API key",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Agent not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "404 Not Found",
                    "value": {
                      "statusCode": 404,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Agent with ID 2g7Xy3tY53gRlp not found",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "500 Internal Server Error",
                    "value": {
                      "statusCode": 500,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Failed to fetch agent: Internal server error",
                      "errors": []
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "summary": "Get Agent Details",
        "tags": [
          "Agents"
        ]
      }
    },
    "/v1/agent-versions/{agentId}/version/{versionNumber}/prompt-review": {
      "post": {
        "description": "Reviews one agent version prompt and configuration without editing or publishing the agent.",
        "operationId": "reviewAgentPrompt",
        "parameters": [
          {
            "name": "agentId",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            },
            "description": "Signed agent ID."
          },
          {
            "name": "versionNumber",
            "required": true,
            "in": "path",
            "schema": {
              "type": "number"
            },
            "description": "Agent version number to review."
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PromptReviewRequest"
              },
              "examples": {
                "focusedReview": {
                  "summary": "Review speech, contradictions, and hallucination risks",
                  "value": {
                    "checks": [
                      "speech",
                      "conflicts",
                      "unknowable"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Prompt review completed.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "error",
                    "statusCode",
                    "message",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "statusCode": {
                      "type": "integer",
                      "example": 201
                    },
                    "message": {
                      "type": "string",
                      "example": "Success"
                    },
                    "data": {
                      "type": "object",
                      "required": [
                        "review_fingerprint",
                        "findings",
                        "new_warning_count",
                        "reviewed_at",
                        "degraded",
                        "cached",
                        "fix_prefill"
                      ],
                      "properties": {
                        "review_fingerprint": {
                          "type": "string",
                          "description": "SHA-256 of the reviewed prompt and the version's default variable names."
                        },
                        "findings": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "required": [
                              "severity",
                              "family",
                              "kind",
                              "message",
                              "fingerprint",
                              "acknowledged"
                            ],
                            "properties": {
                              "severity": {
                                "type": "string",
                                "enum": [
                                  "warning",
                                  "info"
                                ]
                              },
                              "family": {
                                "type": "string",
                                "enum": [
                                  "prompt",
                                  "config"
                                ]
                              },
                              "kind": {
                                "type": "string",
                                "enum": [
                                  "contradiction",
                                  "hallucination_risk",
                                  "undefined_variable",
                                  "unused_variable",
                                  "thin_prompt",
                                  "missing_section",
                                  "tts_dashes",
                                  "instruction_misaligned",
                                  "instruction_inert",
                                  "speech_unfriendly",
                                  "flow_break",
                                  "flow_note",
                                  "branch_gap",
                                  "fallback_without_model",
                                  "fallback_same_as_primary",
                                  "welcome_script_mismatch",
                                  "unused_knowledge_base",
                                  "postcall_field_ungrounded",
                                  "timeout_extreme",
                                  "language_not_configured",
                                  "language_lock_conflict",
                                  "language_switch_unconfigured",
                                  "number_format_conflict",
                                  "language_script_unconfigured",
                                  "language_conflict"
                                ]
                              },
                              "message": {
                                "type": "string"
                              },
                              "evidence": {
                                "type": "string",
                                "nullable": true
                              },
                              "fingerprint": {
                                "type": "string",
                                "pattern": "^[0-9a-f]{40}$"
                              },
                              "acknowledged": {
                                "type": "boolean"
                              }
                            }
                          }
                        },
                        "new_warning_count": {
                          "type": "integer",
                          "minimum": 0
                        },
                        "reviewed_at": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "degraded": {
                          "type": "boolean"
                        },
                        "cached": {
                          "type": "boolean",
                          "description": "True when a stored report was reused. The cache key covers the prompt, the default variable names, the checks and the review engine, not other version settings, so after changing only settings a stored report can be returned."
                        },
                        "fix_prefill": {
                          "type": "string",
                          "nullable": true,
                          "description": "An editing instruction built from up to three unacknowledged warnings, starting \"Fix these prompt review findings:\". Null when there are none."
                        }
                      }
                    },
                    "timestamp": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                },
                "examples": {
                  "success": {
                    "summary": "Review with one warning",
                    "value": {
                      "success": true,
                      "error": false,
                      "statusCode": 201,
                      "message": "Success",
                      "data": {
                        "review_fingerprint": "12a8f88ad6f0f521347705e2af1417f1fc8396f2e2913fcb056082ee1c51723f",
                        "findings": [
                          {
                            "severity": "warning",
                            "family": "prompt",
                            "kind": "contradiction",
                            "message": "The prompt conflicts with the platform's call-time rules: Never end the call until the customer agrees to book a demo.",
                            "evidence": "Never end the call until the customer agrees to book a demo.",
                            "fingerprint": "318c8c636a975f8879bdf2db85a2a0df1d6aa738",
                            "acknowledged": false
                          }
                        ],
                        "new_warning_count": 1,
                        "reviewed_at": "2026-08-31T03:15:00.000Z",
                        "degraded": false,
                        "cached": false,
                        "fix_prefill": "Fix these prompt review findings:\n1) Resolve this contradiction between rules: Never end the call until the customer agrees to book a demo."
                      },
                      "timestamp": "2026-09-07T06:00:00.000Z"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request body: prompt_text is not a string or exceeds 100000 characters, or checks is not an array of known check groups.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Agent version not found in the authenticated workspace.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "summary": "Review An Agent Prompt",
        "tags": [
          "Agents"
        ]
      }
    },
    "/v1/agent-versions/{agentId}/prompt-review/ack": {
      "post": {
        "description": "Accepts or dismisses one prompt review finding for future reviews of the same agent.",
        "operationId": "acknowledgePromptReviewFinding",
        "parameters": [
          {
            "name": "agentId",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            },
            "description": "Signed agent ID of an agent in your workspace."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PromptReviewAcknowledgementRequest"
              },
              "examples": {
                "dismissFinding": {
                  "summary": "Dismiss one reviewed finding",
                  "value": {
                    "finding_fingerprint": "6a763e1fa5d7c82cbb9e54e10d4232cfdd2423ba",
                    "kind": "undefined_variable",
                    "status": "dismissed"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Finding acknowledgement stored.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "error",
                    "statusCode",
                    "message",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "statusCode": {
                      "type": "integer",
                      "example": 201
                    },
                    "message": {
                      "type": "string",
                      "example": "Success"
                    },
                    "data": {
                      "type": "object",
                      "required": [
                        "updated",
                        "finding_fingerprint",
                        "kind",
                        "status",
                        "acked_at"
                      ],
                      "properties": {
                        "updated": {
                          "type": "boolean",
                          "description": "True when an existing acknowledgement was updated."
                        },
                        "finding_fingerprint": {
                          "type": "string",
                          "pattern": "^[0-9a-f]{40}$"
                        },
                        "kind": {
                          "type": "string"
                        },
                        "status": {
                          "type": "string",
                          "enum": [
                            "accepted",
                            "dismissed"
                          ]
                        },
                        "acked_by": {
                          "type": "string",
                          "nullable": true
                        },
                        "acked_at": {
                          "type": "string",
                          "format": "date-time"
                        }
                      }
                    },
                    "timestamp": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                },
                "examples": {
                  "success": {
                    "summary": "New acknowledgement",
                    "value": {
                      "success": true,
                      "error": false,
                      "statusCode": 201,
                      "message": "Success",
                      "data": {
                        "updated": false,
                        "finding_fingerprint": "6a763e1fa5d7c82cbb9e54e10d4232cfdd2423ba",
                        "kind": "undefined_variable",
                        "status": "dismissed",
                        "acked_by": null,
                        "acked_at": "2026-08-31T03:18:00.000Z"
                      },
                      "timestamp": "2026-09-07T06:00:00.000Z"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid finding fingerprint, kind, or status.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "401 error",
                    "value": {
                      "statusCode": 401,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Invalid API key",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "The agent does not exist in the authenticated workspace.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "404 error",
                    "value": {
                      "statusCode": 404,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Agent with ID 2g7Xy3tY53gRlp not found",
                      "errors": []
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "summary": "Acknowledge A Prompt Review Finding",
        "tags": [
          "Agents"
        ]
      }
    },
    "/v1/batch-calls": {
      "post": {
        "description": "Uploads a CSV or Excel file and creates a batch pinned to a published agent version and an outbound number. The response status initiated means accepted; the saved job is waiting or scheduled. Multiple batches can run concurrently within available workspace capacity. A request that fails, for example on row validation, KYC or an unsupported file type, leaves no batch behind.",
        "operationId": "createBatchCall",
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "required": [
                  "file",
                  "title",
                  "agent_id"
                ],
                "properties": {
                  "file": {
                    "type": "string",
                    "format": "binary",
                    "description": "CSV, XLSX or XLS file containing leads (max 10 MB). Needs a phone number column; every number must include its country code."
                  },
                  "title": {
                    "type": "string",
                    "example": "Q3 Follow-up Batch"
                  },
                  "agent_id": {
                    "type": "string",
                    "example": "agent_abc123"
                  },
                  "agent_version_number": {
                    "type": "number",
                    "example": 1,
                    "description": "Must be a published version. Omit to use the agent's latest published version. The batch stays on this version even if the agent is published again."
                  },
                  "phone_number_id": {
                    "type": "string",
                    "example": "phn_abc123",
                    "description": "One of the agent's outbound numbers to dial from. Required when the agent has more than one outbound number."
                  },
                  "starts_at": {
                    "type": "string",
                    "example": "2026-10-15T09:00:00Z",
                    "description": "ISO 8601 datetime: leave empty to start immediately"
                  },
                  "ends_at": {
                    "type": "string",
                    "example": "2026-10-20T18:00:00Z",
                    "description": "ISO 8601 datetime stored with the batch. The scheduler does not enforce it today: calls are not stopped at this time."
                  },
                  "calling_hours_start": {
                    "type": "string",
                    "example": "09:00",
                    "description": "Time of day (for example `09:00`) stored with the batch. The scheduler does not enforce it today. The API does not validate it; a value that is not a valid time returns 500."
                  },
                  "calling_hours_end": {
                    "type": "string",
                    "example": "18:00",
                    "description": "Time of day (for example `18:00`) stored with the batch. The scheduler does not enforce it today. The API does not validate it; a value that is not a valid time returns 500."
                  },
                  "number_of_retries": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 4,
                    "example": 2,
                    "description": "How many times to retry a lead that did not connect, from 0 to 4. Omit both retry fields for no retries. Must be 0 when interval_between_retries is 0, and greater than 0 when it is not; send both fields together."
                  },
                  "interval_between_retries": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 1440,
                    "example": 30,
                    "description": "Minutes to wait between retries, from 0 to 1440. Must be 0 when number_of_retries is 0, and greater than 0 when it is not. Send it whenever number_of_retries is above 0: without it the retry is scheduled with no wait."
                  }
                }
              },
              "examples": {
                "request": {
                  "summary": "Request example",
                  "value": {
                    "file": "leads.csv",
                    "title": "Q3 Follow-up Batch",
                    "agent_id": "agent_abc123",
                    "agent_version_number": 1
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Batch accepted. status is initiated; from_number identifies the selected outbound number. No scheduling-conflict warning is returned.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "example": "batch_abc123"
                    },
                    "total_records": {
                      "type": "number",
                      "example": 250
                    },
                    "dnc_skipped_count": {
                      "type": "number",
                      "example": 0,
                      "description": "Leads left out because their number is on the workspace's DNC list"
                    },
                    "status": {
                      "type": "string",
                      "example": "initiated"
                    },
                    "from_number": {
                      "type": "string",
                      "nullable": true
                    },
                    "title": {
                      "type": "string"
                    }
                  }
                },
                "examples": {
                  "success": {
                    "summary": "Successful response",
                    "value": {
                      "id": "batch_abc123",
                      "total_records": 250,
                      "dnc_skipped_count": 0,
                      "status": "initiated",
                      "from_number": "+14155552671",
                      "title": "Q3 Follow-up Batch"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid file, malformed rows or missing required fields, invalid retry or date fields, rows whose numbers fail validation (with validation_errors and invalid_row_count), the resolved agent version is unpublished, the agent has no outbound number, phone_number_id is not one of its outbound numbers (PHONE_NUMBER_NOT_LINKED), or the agent has several outbound numbers and none was chosen (PHONE_NUMBER_REQUIRED, with phone_number_ids in data).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FilteredErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "400 Bad Request",
                    "value": {
                      "message": "Request validation failed: No valid phone numbers found in CSV"
                    }
                  },
                  "titleTooLong": {
                    "summary": "Title too long",
                    "value": {
                      "message": "Request validation failed: title must be 35 characters or fewer (received 42)."
                    }
                  },
                  "unpublishedVersion": {
                    "summary": "Agent version is still a draft",
                    "value": {
                      "message": "Request validation failed: Version 2 of agent agent_abc123 is a draft. Publish it before starting a call."
                    }
                  },
                  "phoneNumberNotLinked": {
                    "summary": "400 Bad Request",
                    "value": {
                      "message": "Request validation failed: Phone number phn_abc123 is not an outbound number of agent agent_abc123.",
                      "data": {
                        "code": "PHONE_NUMBER_NOT_LINKED"
                      }
                    }
                  },
                  "phoneNumberRequired": {
                    "summary": "400 Bad Request",
                    "value": {
                      "message": "Request validation failed: Agent agent_abc123 has 2 outbound numbers. Pass phone_number_id to choose which one to dial from.",
                      "data": {
                        "code": "PHONE_NUMBER_REQUIRED",
                        "phone_number_ids": [
                          "phn_abc123",
                          "phn_def456"
                        ]
                      }
                    }
                  },
                  "rowValidation": {
                    "summary": "Rows whose numbers fail validation",
                    "value": {
                      "message": "Request validation failed: 1 phone number failed validation.\nPhone Number \"12345\" Could Not Be Parsed. Use International Format Such As +447700900123. (row: 3)",
                      "validation_errors": [
                        {
                          "error": "Phone Number \"12345\" Could Not Be Parsed. Use International Format Such As +447700900123.",
                          "rows": [
                            3
                          ],
                          "phone_numbers": [
                            "12345"
                          ]
                        }
                      ],
                      "invalid_row_count": 1
                    }
                  },
                  "allNumbersOnDnc": {
                    "summary": "Every number is on the DNC list",
                    "value": {
                      "message": "Request validation failed: All 2 numbers in this file are on your workspace's DNC list, so there is nothing to call."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FilteredErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "401 Unauthorized",
                    "value": {
                      "message": "API key is missing or invalid. You can generate this by logging in into dashboard"
                    }
                  }
                }
              }
            }
          },
          "402": {
            "description": "The workspace has no billing plan or no spendable balance, or its monthly spend cap is reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FilteredErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "402 Payment Required",
                    "value": {
                      "message": "Insufficient wallet credits. Please recharge to create campaigns."
                    }
                  },
                  "spendCapReached": {
                    "summary": "Monthly spend cap reached",
                    "value": {
                      "message": "Monthly spend cap reached (₹5,000.00 of ₹5,000.00 used). Raise it in Billing → Balance alerts, or it resets on 1 Nov."
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "The workspace owner's KYC is not verified and a lead's phone number is not the owner's registered number (not enforced for SIP numbers).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FilteredErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "KYC pending: destinations limited to the owner's registered phone",
                    "value": {
                      "message": "Verify Your KYC to schedule a batch"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Agent not found in the workspace, the requested agent version does not exist, or the uploaded file is not a .csv, .xls or .xlsx file (Unsupported file type).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FilteredErrorResponse"
                },
                "examples": {
                  "versionNotFound": {
                    "summary": "Agent version not found",
                    "value": {
                      "message": "Agent agent_abc123 has no version 9. Published versions: 1, 3."
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "The uploaded file is larger than 10 MB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FilteredErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "413 Payload Too Large",
                    "value": {
                      "message": "An unexpected error occurred. Please try again later."
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FilteredErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "500 Internal Server Error",
                    "value": {
                      "message": "An unexpected error occurred. Please try again later."
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "summary": "Create Batch Call",
        "tags": [
          "Batch Calls"
        ]
      },
      "get": {
        "operationId": "listBatchCalls",
        "parameters": [
          {
            "name": "page",
            "required": false,
            "in": "query",
            "description": "Page number, starting from 1.",
            "schema": {
              "minimum": 1,
              "default": 1,
              "type": "integer"
            }
          },
          {
            "name": "limit",
            "required": false,
            "in": "query",
            "description": "Results per page.",
            "schema": {
              "minimum": 1,
              "default": 30,
              "type": "integer"
            }
          },
          {
            "name": "sortBy",
            "required": false,
            "in": "query",
            "description": "Field to sort by.",
            "schema": {
              "default": "created_at",
              "type": "string",
              "enum": [
                "created_at",
                "updated_at",
                "createdAt",
                "updatedAt",
                "title",
                "status",
                "id"
              ]
            }
          },
          {
            "name": "sortOrder",
            "required": false,
            "in": "query",
            "description": "Sort direction.",
            "schema": {
              "default": "DESC",
              "type": "string",
              "enum": [
                "ASC",
                "DESC"
              ]
            }
          },
          {
            "name": "status",
            "required": false,
            "in": "query",
            "description": "Filter by batch status. One value or a comma-separated list of: draft, active, running, paused, completed, cancelled, deleted, scheduled, waiting.",
            "schema": {
              "example": "running,paused",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Batch calls returned successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string",
                        "example": "batch_abc123"
                      },
                      "status": {
                        "type": "string",
                        "description": "Current batch status, for example waiting, scheduled, running, paused, completed or cancelled."
                      },
                      "title": {
                        "type": "string"
                      },
                      "created_at": {
                        "type": "string",
                        "format": "date-time",
                        "description": "When the batch was created."
                      }
                    }
                  }
                },
                "examples": {
                  "success": {
                    "summary": "Successful response",
                    "value": [
                      {
                        "id": "batch_abc123",
                        "status": "waiting",
                        "title": "Q3 Follow-up Batch"
                      }
                    ]
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid query parameters.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FilteredErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "400 Bad Request",
                    "value": {
                      "message": "Request validation failed: page must not be less than 1"
                    }
                  },
                  "invalidStatus": {
                    "summary": "Unknown status filter",
                    "value": {
                      "message": "Request validation failed: Error fetching campaigns: Invalid campaign status filter: done. Allowed values: draft, active, running, paused, completed, cancelled, deleted, scheduled, waiting."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FilteredErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "401 Unauthorized",
                    "value": {
                      "message": "API key is missing or invalid. You can generate this by logging in into dashboard"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FilteredErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "500 Internal Server Error",
                    "value": {
                      "message": "An unexpected error occurred. Please try again later."
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "summary": "List Batch Calls",
        "tags": [
          "Batch Calls"
        ],
        "description": "Returns a page of batch jobs, newest first by default, as a root JSON array of ID, title, status, and creation time."
      }
    },
    "/v1/batch-calls/{id}": {
      "get": {
        "operationId": "getBatchCall",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "description": "Batch call ID",
            "schema": {
              "example": "batch_abc123",
              "type": "string"
            }
          },
          {
            "name": "agent_id",
            "required": false,
            "in": "query",
            "description": "Filter by agent ID: one ID or a comma-separated list (e.g., agent_abc,agent_def). Ignored when agent_version_id is sent, and replaced by agent_version_name when that name matches a version.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "call_id",
            "required": false,
            "in": "query",
            "description": "Filter by call ID - can be a single ID or comma-separated list (e.g., call_abc,call_def)",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "from",
            "required": false,
            "in": "query",
            "description": "Filter by the workspace phone number on the call (the number dialled from, or for an inbound call the number that was called), as a partial match on its digits.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "to",
            "required": false,
            "in": "query",
            "description": "Filter by recipient phone number, as a partial match on the batch lead's number as stored. The value is not reduced to digits, and Indian lead numbers are stored as `91XXXXXXXXXX` without `+`, so send digits only. Only batch calls carry a lead, so single calls and retry attempts never match this filter.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "type",
            "required": false,
            "in": "query",
            "description": "Filter by call type: one value or a comma-separated list of `phone`, `web`.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "call_direction",
            "required": false,
            "in": "query",
            "description": "Filter by call direction: one value or a comma-separated list of `inbound`, `outbound`.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "agent_version_id",
            "required": false,
            "in": "query",
            "description": "Filter batch calls by agent version, written as `<agent_id>-<version_number>` (for example `agent_2g7Xy3tY53gRlp-3`); one value or a comma-separated list. Only calls placed by a batch match. A value in any other format is ignored, and when no value is valid the whole filter is dropped. When this parameter is sent, `agent_id` is not applied.",
            "schema": {
              "type": "string",
              "example": "agent_2g7Xy3tY53gRlp-3"
            }
          },
          {
            "name": "agent_version_name",
            "required": false,
            "in": "query",
            "description": "Search by agent version name (partial match, case-insensitive)",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sentiment",
            "required": false,
            "in": "query",
            "description": "Filter by user sentiment: one value or a comma-separated list of `positive`, `neutral`, `negative`, `unknown`.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "start_date",
            "required": false,
            "in": "query",
            "description": "Return calls created on or after the start of this day in UTC (ISO 8601). The value is converted to UTC first, then widened to 00:00:00 UTC of that day, so a time with an offset can move the day. Send a plain date (`YYYY-MM-DD`).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "end_date",
            "required": false,
            "in": "query",
            "description": "Return calls created on or before the end of this day in UTC (ISO 8601). The value is converted to UTC first, then widened to 23:59:59.999 UTC of that day, so a time with an offset can move the day. Send a plain date (`YYYY-MM-DD`).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "duration_greater_than",
            "required": false,
            "in": "query",
            "description": "Return calls longer than this many seconds.",
            "schema": {
              "minimum": 0,
              "type": "number"
            }
          },
          {
            "name": "duration_less_than",
            "required": false,
            "in": "query",
            "description": "Return calls shorter than this many seconds.",
            "schema": {
              "minimum": 0,
              "type": "number"
            }
          },
          {
            "name": "duration_min",
            "required": false,
            "in": "query",
            "description": "Lower bound of a duration range in seconds, inclusive. Applied only together with duration_max; sent alone it is ignored.",
            "schema": {
              "minimum": 0,
              "type": "number"
            }
          },
          {
            "name": "duration_max",
            "required": false,
            "in": "query",
            "description": "Upper bound of a duration range in seconds, inclusive. Applied only together with duration_min; sent alone it is ignored.",
            "schema": {
              "minimum": 0,
              "type": "number"
            }
          },
          {
            "name": "page",
            "required": false,
            "in": "query",
            "description": "Page number (starts from 1)",
            "schema": {
              "minimum": 1,
              "example": 1,
              "type": "integer"
            }
          },
          {
            "name": "limit",
            "required": false,
            "in": "query",
            "description": "Number of records per page. Minimum 1, maximum 200.",
            "schema": {
              "minimum": 1,
              "maximum": 200,
              "default": 20,
              "example": 20,
              "type": "integer"
            }
          },
          {
            "name": "created_at",
            "required": false,
            "in": "query",
            "description": "Sort by created_at (asc or desc)",
            "schema": {
              "type": "string",
              "enum": [
                "asc",
                "desc"
              ]
            }
          },
          {
            "name": "duration",
            "required": false,
            "in": "query",
            "description": "Sort by duration (asc or desc)",
            "schema": {
              "type": "string",
              "enum": [
                "asc",
                "desc"
              ]
            }
          },
          {
            "name": "status",
            "required": false,
            "in": "query",
            "description": "Filter by call status: one value or a comma-separated list, for example completed,failed. Values: initiated, received, sent, did_not_pick, busy, failed, no_answer, completed, created, cancelled, retry_expired. An unknown value returns 400.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "export",
            "required": false,
            "in": "query",
            "description": "Set to `true` to return every matching call in one JSON array without pagination, up to the export row limit, including retry attempts. Omit it or send `false` to receive pages. For a batch export, the row limit counts the original calls only; retry attempts are added on top, so the array can be longer.",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "end_reason",
            "required": false,
            "in": "query",
            "description": "Filter by why the call ended: one value or a comma-separated list of `agent_disconnected`, `user_disconnected`, `user_busy`, `user_did_not_pick_up`, `invalid_phone_number`, `unallocated_phone_number`, `unknown`, `network_failure`, `voicemail_detected`, `user_unreachable`, `destination_forbidden`, `system_failure`, `system_at_capacity`, `insufficient_balance`, `agent_not_found`, `sip_auth_failed`, `sip_trunk_unreachable`, `spend_cap_reached`, `dnc_blocked`. Unknown values are ignored; if no value is known, no calls match.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "is_ivr",
            "required": false,
            "in": "query",
            "description": "Filter by whether the call was handled by an IVR agent (matched by the call's agent and/or the IVR billing flag, so both promoted/transferred and pure menu calls count). true = IVR calls only; false = non-IVR calls only; omit for all.",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "tags",
            "required": false,
            "in": "query",
            "description": "Filter by lead tags: the tags attached to the workflow lead when its leads file was uploaded, snapshotted onto the call when it was placed. Comma-separated for multiple values. Matching is case-insensitive because tags are normalized to lowercase on upload. Use tags_match to choose ANY (default) or ALL.",
            "schema": {
              "example": "priority,q3-campaign",
              "type": "string"
            }
          },
          {
            "name": "tags_match",
            "required": false,
            "in": "query",
            "description": "How multiple `tags` values combine: \"any\" returns calls carrying at least one of them (default), \"all\" returns only calls carrying every one of them.",
            "schema": {
              "default": "any",
              "type": "string",
              "enum": [
                "any",
                "all"
              ]
            }
          },
          {
            "name": "columns",
            "required": false,
            "in": "query",
            "description": "Export only: comma-separated list of column keys being exported (e.g. \"duration,status,end_reason\"). Lets the server skip fetching heavy columns nobody asked for, which raises the export row limit. Omit to fetch everything, as before.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "agent_type",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "single_prompt",
                "conversational_flow",
                "speech_to_speech",
                "ivr"
              ]
            },
            "description": "Filter by agent type. ivr is equivalent to is_ivr=true and includes IVR handoffs. Other types require an agent ID retained on the call; calls without one do not match those types."
          }
        ],
        "responses": {
          "200": {
            "description": "Calls in the batch returned successfully.",
            "content": {
              "application/json": {
                "examples": {
                  "success": {
                    "summary": "Calls in the batch",
                    "value": [
                      {
                        "id": "call_abc123",
                        "agent_id": "agent_2g7Xy3tY53gRlp",
                        "batch_id": "batch_abc123",
                        "to_number": "919876543210",
                        "phone_number_id": "phn_abc123",
                        "duration": "42",
                        "status": "completed",
                        "end_reason": "user_disconnected",
                        "llm_name": "gpt-4o"
                      }
                    ]
                  }
                },
                "schema": {
                  "type": "array",
                  "description": "The calls created for this batch, one record per lead. Paginated with page and limit unless export=true; retry attempts appear only with export=true.",
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string",
                        "example": "call_abc123",
                        "description": "Signed call ID."
                      },
                      "agent_id": {
                        "type": "string",
                        "nullable": true,
                        "example": "agent_2g7Xy3tY53gRlp",
                        "description": "Agent that handled the call."
                      },
                      "batch_id": {
                        "type": "string",
                        "nullable": true,
                        "example": "batch_abc123",
                        "description": "Signed batch ID of the batch the call belongs to; null for single calls and for retry attempts."
                      },
                      "from_number": {
                        "type": "string",
                        "nullable": true,
                        "description": "Number that placed the call: your DialNexa number for an outbound call, and the caller's number for an inbound call. Returned as recorded, so it may not start with `+`. Null for a web call.",
                        "example": "+918012345678"
                      },
                      "to_number": {
                        "type": "string",
                        "nullable": true,
                        "example": "919876543210",
                        "description": "Number that received the call: the contact's number for an outbound call, and your DialNexa number for an inbound call. Returned as recorded: for a batch call it is the lead's stored number, where an Indian number appears as `91XXXXXXXXXX` without `+`."
                      },
                      "call_direction": {
                        "type": "string",
                        "nullable": true,
                        "description": "Direction of the call: `inbound` or `outbound`. Calls in a batch are always `outbound`.",
                        "example": "outbound"
                      },
                      "phone_number_id": {
                        "type": "string",
                        "nullable": true,
                        "example": "phn_abc123",
                        "description": "ID of the workspace phone number the call was placed from."
                      },
                      "called_time": {
                        "type": "string",
                        "nullable": true,
                        "format": "date-time",
                        "description": "When the call was placed."
                      },
                      "duration": {
                        "type": "string",
                        "example": "42",
                        "description": "Call duration in seconds, serialized as a string (the column is a 64-bit integer); null until a duration is recorded.",
                        "nullable": true
                      },
                      "status": {
                        "type": "string",
                        "example": "completed",
                        "description": "Current call status."
                      },
                      "initiated_time": {
                        "type": "string",
                        "nullable": true,
                        "format": "date-time",
                        "description": "When the call was initiated on the telephony side."
                      },
                      "end_reason": {
                        "type": "string",
                        "nullable": true,
                        "example": "user_disconnected",
                        "description": "Why the call ended; `unknown` until the call ends. One of `agent_disconnected`, `user_disconnected`, `user_busy`, `user_did_not_pick_up`, `invalid_phone_number`, `unallocated_phone_number`, `unknown`, `network_failure`, `voicemail_detected`, `user_unreachable`, `destination_forbidden`, `system_failure`, `system_at_capacity`, `insufficient_balance`, `agent_not_found`, `sip_auth_failed`, `sip_trunk_unreachable`, `spend_cap_reached`, `dnc_blocked`."
                      },
                      "postcallanalysis": {
                        "type": "object",
                        "nullable": true,
                        "additionalProperties": true,
                        "description": "Post-call analysis fields extracted for this call, keyed by field name. An empty object until analysis has run."
                      },
                      "llm_name": {
                        "type": "string",
                        "nullable": true,
                        "example": "gpt-4o",
                        "description": "Display name of the language model used on the call."
                      },
                      "voice_model_name": {
                        "type": "string",
                        "nullable": true,
                        "description": "Display name of the voice used on the call."
                      },
                      "recording_sas_url": {
                        "type": "string",
                        "nullable": true,
                        "description": "Time-limited link to the recording. Absent from the response unless export=true."
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FilteredErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "401 Unauthorized",
                    "value": {
                      "message": "API key is missing or invalid. You can generate this by logging in into dashboard"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FilteredErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "500 Internal Server Error",
                    "value": {
                      "message": "An unexpected error occurred. Please try again later."
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid query parameters.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FilteredErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "400 Bad Request",
                    "value": {
                      "message": "Request validation failed: limit must not be greater than 200"
                    }
                  },
                  "unknownFilterValue": {
                    "summary": "Unknown filter value",
                    "value": {
                      "message": "Request validation failed: Invalid status filter value: foo. Allowed values: initiated, received, sent, did_not_pick, busy, failed, no_answer, completed, created, cancelled, retry_expired"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "summary": "Get Batch Call Details",
        "tags": [
          "Batch Calls"
        ],
        "description": "Returns the calls created for one batch as a root JSON array, paginated with page and limit unless export=true. An unknown batch ID, or one from another workspace, returns an empty array. Paginated results leave out retry attempts; export=true includes them."
      }
    },
    "/v1/batch-calls/{id}/status": {
      "patch": {
        "operationId": "updateBatchCallStatus",
        "summary": "Update Batch Call Status",
        "description": "Changes the execution status of a batch call. Use `pause` to halt new outbound calls, `resume` to continue a paused batch, or `cancel` to permanently stop the batch and remove queued calls.",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "description": "Batch call ID",
            "schema": {
              "example": "batch_abc123",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateBatchCallStatusRequest"
              },
              "examples": {
                "pause": {
                  "summary": "Pause a batch call",
                  "value": {
                    "action": "pause"
                  }
                },
                "resume": {
                  "summary": "Resume a batch call",
                  "value": {
                    "action": "resume"
                  }
                },
                "cancel": {
                  "summary": "Cancel a batch call",
                  "value": {
                    "action": "cancel"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Batch call status updated successfully.",
            "content": {
              "application/json": {
                "examples": {
                  "success": {
                    "summary": "Successful response",
                    "value": {}
                  }
                },
                "schema": {
                  "type": "object",
                  "properties": {}
                }
              }
            }
          },
          "400": {
            "description": "Invalid action, or action not allowed for the current batch call status.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FilteredErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "400 Bad Request",
                    "value": {
                      "message": "Request validation failed: action must be one of the following values: pause, resume, cancel"
                    }
                  },
                  "notAllowed": {
                    "summary": "Action not allowed for the batch status",
                    "value": {
                      "message": "Request validation failed: Campaign status 'paused' is not allowed. Required status: running or waiting"
                    }
                  },
                  "finalState": {
                    "summary": "Batch already finished",
                    "value": {
                      "message": "Request validation failed: Campaign status 'completed' is not allowed. Campaign is already in a final state."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FilteredErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "401 Unauthorized",
                    "value": {
                      "message": "API key is missing or invalid. You can generate this by logging in into dashboard"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Batch call not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FilteredErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "404 Not Found",
                    "value": {
                      "message": "Campaign with ID 2g7Xy3tY53gRlp not found"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FilteredErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "500 Internal Server Error",
                    "value": {
                      "message": "An unexpected error occurred. Please try again later."
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "tags": [
          "Batch Calls"
        ]
      }
    },
    "/v1/calls": {
      "post": {
        "description": "Schedules a single outbound call. The call is queued and initiated when resources are available.",
        "operationId": "createCall",
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateCallRequest"
              },
              "examples": {
                "request": {
                  "summary": "Create an outbound call",
                  "value": {
                    "agent_id": "agent_2g7Xy3tY53gRlp",
                    "phone_number": "+919876543210",
                    "agent_version_number": 1,
                    "metadata": {}
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Call created and queued successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "example": "call_mfgsn90vwcozgb",
                      "description": "Unique call ID for tracking. Use this ID to reference the call in other API endpoints."
                    },
                    "agent_id": {
                      "type": "string",
                      "example": "agent_mfgsn90vwcozgb",
                      "description": "The ID of the agent used for this call."
                    },
                    "to_phone_number": {
                      "type": "string",
                      "example": "+911234567890",
                      "description": "The phone number that will receive the call."
                    },
                    "agent_version_number": {
                      "type": "number",
                      "example": 2,
                      "description": "Numeric agent version actually selected for this call. If omitted in the request, the latest published version is selected."
                    }
                  },
                  "required": [
                    "id",
                    "to_phone_number",
                    "agent_id"
                  ]
                },
                "examples": {
                  "success": {
                    "summary": "Successful response",
                    "value": {
                      "id": "call_abc123",
                      "agent_id": "agent_2g7Xy3tY53gRlp",
                      "to_phone_number": "+919876543210",
                      "agent_version_number": 1
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request body or destination number, invalid metadata.agent_transfer_destinations, notes with more than 15 keys, the agent has no outbound number, phone_number_id is not one of its outbound numbers (PHONE_NUMBER_NOT_LINKED), or the agent has several outbound numbers and none was chosen (PHONE_NUMBER_REQUIRED, with phone_number_ids in data).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FilteredErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "400 Bad Request",
                    "value": {
                      "message": "Request validation failed: phone_number must be a string"
                    }
                  },
                  "phoneNumberNotLinked": {
                    "summary": "400 Bad Request",
                    "value": {
                      "message": "Request validation failed: Phone number phn_2g7Xy3tY53gRlp is not an outbound number of agent agent_mgao6051Rk718Y.",
                      "data": {
                        "code": "PHONE_NUMBER_NOT_LINKED"
                      }
                    }
                  },
                  "phoneNumberRequired": {
                    "summary": "400 Bad Request",
                    "value": {
                      "message": "Request validation failed: Agent agent_mgao6051Rk718Y has 2 outbound numbers. Pass phone_number_id to choose which one to dial from.",
                      "data": {
                        "code": "PHONE_NUMBER_REQUIRED",
                        "phone_number_ids": [
                          "phn_2g7Xy3tY53gRlp",
                          "phn_8Kd2mQ4vX9pLs1"
                        ]
                      }
                    }
                  },
                  "llmRetired": {
                    "summary": "Agent version uses a retired LLM",
                    "value": {
                      "message": "Request validation failed: This agent version uses GPT-4.1 Nano, which has been retired. Switch to a supported model and publish a new version.",
                      "data": {
                        "code": "LLM_RETIRED",
                        "llm_ids": [
                          "meqtu4wiqv5haq"
                        ]
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FilteredErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "401 Unauthorized",
                    "value": {
                      "message": "API key is missing or invalid. You can generate this by logging in into dashboard"
                    }
                  }
                }
              }
            }
          },
          "402": {
            "description": "The wallet has no spendable balance, or the workspace's monthly spend cap is reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FilteredErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "402 Payment Required",
                    "value": {
                      "message": "Insufficient balance. Please top up your billing wallet before making a call.."
                    }
                  },
                  "spendCapReached": {
                    "summary": "Monthly spend cap reached",
                    "value": {
                      "message": "Monthly spend cap reached (₹5,000.00 of ₹5,000.00 used). Raise it in Billing → Balance alerts, or it resets on 1 Nov."
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "The destination country or network prefix is not enabled for this workspace, or the workspace owner's KYC is not verified and the destination is not the owner's registered number (KYC rule not enforced for SIP numbers), or the destination number is on the workspace's DNC list.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FilteredErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "403 Forbidden",
                    "value": {
                      "message": "Country US Is Not Enabled For Outbound Calls From +91 Numbers. Enabled Countries: India (IN)."
                    }
                  },
                  "dncBlocked": {
                    "summary": "Number on the DNC list",
                    "value": {
                      "message": "This number is on your workspace's DNC list and cannot be called. Remove it from Workspace Settings > Telephony > DNC list to call it."
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Agent not found in your organization, or it has no published version (or the requested agent_version_number is not published).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FilteredErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "404 Not Found",
                    "value": {
                      "message": "Agent mgao6051Rk718Y not found or doesn't belong to organization 7Hk2pQ9rT1xY4z"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FilteredErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "500 Internal Server Error",
                    "value": {
                      "message": "An unexpected error occurred. Please try again later."
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "summary": "Create Call",
        "tags": [
          "Calls"
        ]
      },
      "get": {
        "operationId": "listCalls",
        "parameters": [
          {
            "name": "agent_id",
            "required": false,
            "in": "query",
            "description": "Filter by agent ID: one ID or a comma-separated list (e.g., agent_abc,agent_def). Ignored when agent_version_id is sent, and replaced by agent_version_name when that name matches a version.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "call_id",
            "required": false,
            "in": "query",
            "description": "Filter by call ID - single or comma-separated list (e.g., call_abc,call_def)",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "batch_call_id",
            "required": false,
            "in": "query",
            "description": "Filter by batch call ID - single or comma-separated list (e.g., batch_abc,batch_def). With export=true, every matching call of those batches is returned in one JSON array.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "from",
            "required": false,
            "in": "query",
            "description": "Filter by the workspace phone number on the call (the number dialled from, or for an inbound call the number that was called), as a partial match on its digits.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "to",
            "required": false,
            "in": "query",
            "description": "Filter by recipient phone number, as a partial match on the batch lead's number as stored. The value is not reduced to digits, and Indian lead numbers are stored as `91XXXXXXXXXX` without `+`, so send digits only. Only batch calls carry a lead, so single calls and retry attempts never match this filter.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "type",
            "required": false,
            "in": "query",
            "description": "Filter by call type: one value or a comma-separated list of `phone`, `web`.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "call_direction",
            "required": false,
            "in": "query",
            "description": "Filter by call direction: one value or a comma-separated list of `inbound`, `outbound`.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "agent_version_id",
            "required": false,
            "in": "query",
            "description": "Filter batch calls by agent version, written as `<agent_id>-<version_number>` (for example `agent_2g7Xy3tY53gRlp-3`); one value or a comma-separated list. Only calls placed by a batch match. A value in any other format is ignored, and when no value is valid the whole filter is dropped. When this parameter is sent, `agent_id` is not applied.",
            "schema": {
              "type": "string",
              "example": "agent_2g7Xy3tY53gRlp-3"
            }
          },
          {
            "name": "agent_version_name",
            "required": false,
            "in": "query",
            "description": "Search by agent version name (partial match, case-insensitive)",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sentiment",
            "required": false,
            "in": "query",
            "description": "Filter by user sentiment: one value or a comma-separated list of `positive`, `neutral`, `negative`, `unknown`.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "start_date",
            "required": false,
            "in": "query",
            "description": "Return calls created on or after the start of this day in UTC (ISO 8601). The value is converted to UTC first, then widened to 00:00:00 UTC of that day, so a time with an offset can move the day. Send a plain date (`YYYY-MM-DD`).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "end_date",
            "required": false,
            "in": "query",
            "description": "Return calls created on or before the end of this day in UTC (ISO 8601). The value is converted to UTC first, then widened to 23:59:59.999 UTC of that day, so a time with an offset can move the day. Send a plain date (`YYYY-MM-DD`).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "duration_greater_than",
            "required": false,
            "in": "query",
            "description": "Return calls longer than this many seconds.",
            "schema": {
              "minimum": 0,
              "type": "number"
            }
          },
          {
            "name": "duration_less_than",
            "required": false,
            "in": "query",
            "description": "Return calls shorter than this many seconds.",
            "schema": {
              "minimum": 0,
              "type": "number"
            }
          },
          {
            "name": "duration_min",
            "required": false,
            "in": "query",
            "description": "Lower bound of a duration range in seconds, inclusive. Applied only together with duration_max; sent alone it is ignored.",
            "schema": {
              "minimum": 0,
              "type": "number"
            }
          },
          {
            "name": "duration_max",
            "required": false,
            "in": "query",
            "description": "Upper bound of a duration range in seconds, inclusive. Applied only together with duration_min; sent alone it is ignored.",
            "schema": {
              "minimum": 0,
              "type": "number"
            }
          },
          {
            "name": "page",
            "required": false,
            "in": "query",
            "description": "Page number (default: 1)",
            "schema": {
              "minimum": 1,
              "type": "integer"
            }
          },
          {
            "name": "limit",
            "required": false,
            "in": "query",
            "description": "Results per page (default: 20)",
            "schema": {
              "minimum": 1,
              "maximum": 200,
              "default": 20,
              "type": "integer"
            }
          },
          {
            "name": "created_at",
            "required": false,
            "in": "query",
            "description": "Sort by creation date",
            "schema": {
              "enum": [
                "asc",
                "desc"
              ],
              "type": "string"
            }
          },
          {
            "name": "duration",
            "required": false,
            "in": "query",
            "description": "Sort by call duration",
            "schema": {
              "enum": [
                "asc",
                "desc"
              ],
              "type": "string"
            }
          },
          {
            "name": "status",
            "required": false,
            "in": "query",
            "description": "Filter by call status: one value or a comma-separated list, for example completed,failed. Values: initiated, received, sent, did_not_pick, busy, failed, no_answer, completed, created, cancelled, retry_expired. An unknown value returns 400.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "export",
            "required": false,
            "in": "query",
            "description": "Set to `true` to return every matching call in one JSON array without pagination, up to the export row limit, including retry attempts. Omit it or send `false` to receive pages. For a batch export, the row limit counts the original calls only; retry attempts are added on top, so the array can be longer.",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "end_reason",
            "required": false,
            "in": "query",
            "description": "Filter by why the call ended: one value or a comma-separated list of `agent_disconnected`, `user_disconnected`, `user_busy`, `user_did_not_pick_up`, `invalid_phone_number`, `unallocated_phone_number`, `unknown`, `network_failure`, `voicemail_detected`, `user_unreachable`, `destination_forbidden`, `system_failure`, `system_at_capacity`, `insufficient_balance`, `agent_not_found`, `sip_auth_failed`, `sip_trunk_unreachable`, `spend_cap_reached`, `dnc_blocked`. Unknown values are ignored; if no value is known, no calls match.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "columns",
            "required": false,
            "in": "query",
            "description": "Export only: comma-separated list of column keys being exported (e.g. \"duration,status,end_reason\"). Lets the server skip fetching heavy columns nobody asked for, which raises the export row limit. Omit to fetch everything, as before.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "is_ivr",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean"
            },
            "description": "True for IVR calls including handoffs, false for other calls; omit for all."
          },
          {
            "name": "tags",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "example": "priority,september"
            },
            "description": "Comma-separated workflow lead tags copied to calls when placed."
          },
          {
            "name": "tags_match",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "any",
                "all"
              ],
              "default": "any"
            },
            "description": "Whether calls must match any or all supplied tags."
          },
          {
            "name": "agent_type",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "single_prompt",
                "conversational_flow",
                "speech_to_speech",
                "ivr"
              ]
            },
            "description": "Filter by agent type. ivr is equivalent to is_ivr=true and includes IVR handoffs. Other types require an agent ID retained on the call; calls without one do not match those types."
          }
        ],
        "responses": {
          "200": {
            "description": "Calls returned successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string",
                        "example": "call_abc123",
                        "description": "Signed call ID"
                      },
                      "agent_id": {
                        "type": "string",
                        "nullable": true,
                        "example": "agent_2g7Xy3tY53gRlp",
                        "description": "Agent that handled the call."
                      },
                      "batch_id": {
                        "type": "string",
                        "nullable": true,
                        "description": "Signed batch ID of the batch the call belongs to; null for single calls and for retry attempts."
                      },
                      "from_number": {
                        "type": "string",
                        "nullable": true,
                        "description": "Number that placed the call: your DialNexa number for an outbound call, and the caller's number for an inbound call. Returned as recorded, so it may not start with `+`. Null for a web call.",
                        "example": "+918012345678"
                      },
                      "to_number": {
                        "type": "string",
                        "nullable": true,
                        "example": "+919876543210",
                        "description": "Number that received the call: the contact's number for an outbound call, and your DialNexa number for an inbound call. Returned as recorded: for a batch call it is the lead's stored number, where an Indian number appears as `91XXXXXXXXXX` without `+`."
                      },
                      "call_direction": {
                        "type": "string",
                        "description": "Direction of the call: `inbound` or `outbound`.",
                        "example": "outbound"
                      },
                      "phone_number_id": {
                        "type": "string",
                        "nullable": true,
                        "example": "phn_abc123",
                        "description": "ID of the workspace phone number the call was placed from."
                      },
                      "called_time": {
                        "format": "date-time",
                        "type": "string"
                      },
                      "duration": {
                        "type": "string",
                        "example": "42",
                        "description": "Call duration in seconds, serialized as a string (the column is a 64-bit integer); null until a duration is recorded.",
                        "nullable": true
                      },
                      "status": {
                        "type": "string"
                      },
                      "initiated_time": {
                        "type": "string"
                      },
                      "end_reason": {
                        "type": "string",
                        "description": "Why the call ended; `unknown` until the call ends. One of `agent_disconnected`, `user_disconnected`, `user_busy`, `user_did_not_pick_up`, `invalid_phone_number`, `unallocated_phone_number`, `unknown`, `network_failure`, `voicemail_detected`, `user_unreachable`, `destination_forbidden`, `system_failure`, `system_at_capacity`, `insufficient_balance`, `agent_not_found`, `sip_auth_failed`, `sip_trunk_unreachable`, `spend_cap_reached`, `dnc_blocked`."
                      },
                      "postcallanalysis": {
                        "type": "object",
                        "nullable": true,
                        "additionalProperties": true,
                        "description": "Post-call analysis fields extracted for this call, keyed by field name. An empty object until analysis has run."
                      },
                      "llm_name": {
                        "type": "string",
                        "nullable": true,
                        "example": "gpt-4o",
                        "description": "Display name of the language model used on the call."
                      },
                      "voice_model_name": {
                        "type": "string",
                        "nullable": true,
                        "description": "Display name of the voice used on the call."
                      },
                      "recording_sas_url": {
                        "type": "string",
                        "nullable": true,
                        "description": "Time-limited link to the recording. Absent from the response unless export=true."
                      }
                    },
                    "required": [
                      "id"
                    ]
                  }
                },
                "examples": {
                  "success": {
                    "summary": "Successful response",
                    "value": [
                      {
                        "id": "call_abc123",
                        "agent_id": "agent_2g7Xy3tY53gRlp",
                        "to_number": "+919876543210",
                        "duration": "42",
                        "status": "completed",
                        "end_reason": "user_disconnected"
                      }
                    ]
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request - invalid query parameters.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FilteredErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "400 Bad Request",
                    "value": {
                      "message": "Request validation failed: limit must not be greater than 200"
                    }
                  },
                  "unknownFilterValue": {
                    "summary": "Unknown filter value",
                    "value": {
                      "message": "Request validation failed: Invalid status filter value: foo. Allowed values: initiated, received, sent, did_not_pick, busy, failed, no_answer, completed, created, cancelled, retry_expired"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FilteredErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "401 Unauthorized",
                    "value": {
                      "message": "API key is missing or invalid. You can generate this by logging in into dashboard"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FilteredErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "500 Internal Server Error",
                    "value": {
                      "message": "An unexpected error occurred. Please try again later."
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "summary": "List Calls",
        "tags": [
          "Calls"
        ],
        "description": "Returns calls for the authenticated workspace using the supplied filters, newest records first (a `duration` sort orders by duration instead, and an export of one batch follows the lead file order), as a root JSON array without pagination metadata. Paginated results leave out retry attempts; send `export=true` or `call_id` to include them."
      }
    },
    "/v1/calls/{id}": {
      "get": {
        "operationId": "getCall",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "description": "Call ID",
            "schema": {
              "example": "call_abc123",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Call returned successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "example": "call_abc123",
                      "description": "Signed call ID"
                    },
                    "agent_id": {
                      "type": "string",
                      "nullable": true,
                      "example": "agent_2g7Xy3tY53gRlp",
                      "description": "Agent that handled the call."
                    },
                    "batch_id": {
                      "type": "string",
                      "nullable": true,
                      "description": "Signed batch ID of the batch the call belongs to; null for single calls and for retry attempts."
                    },
                    "from_number": {
                      "type": "string",
                      "nullable": true,
                      "description": "Number that placed the call: your DialNexa number for an outbound call, and the caller's number for an inbound call. Returned as recorded, so it may not start with `+`. Null for a web call.",
                      "example": "+918012345678"
                    },
                    "to_number": {
                      "type": "string",
                      "nullable": true,
                      "example": "+919876543210",
                      "description": "Number that received the call: the contact's number for an outbound call, and your DialNexa number for an inbound call. Returned as recorded: for a batch call it is the lead's stored number, where an Indian number appears as `91XXXXXXXXXX` without `+`."
                    },
                    "call_direction": {
                      "type": "string",
                      "description": "Direction of the call: `inbound` or `outbound`.",
                      "example": "outbound"
                    },
                    "phone_number_id": {
                      "type": "string",
                      "nullable": true,
                      "example": "phn_abc123",
                      "description": "ID of the workspace phone number the call was placed from."
                    },
                    "called_time": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "duration": {
                      "type": "string",
                      "example": "42",
                      "description": "Call duration in seconds, serialized as a string (the column is a 64-bit integer); null until a duration is recorded.",
                      "nullable": true
                    },
                    "status": {
                      "type": "string"
                    },
                    "initiated_time": {
                      "type": "string"
                    },
                    "end_reason": {
                      "type": "string",
                      "description": "Why the call ended; `unknown` until the call ends. One of `agent_disconnected`, `user_disconnected`, `user_busy`, `user_did_not_pick_up`, `invalid_phone_number`, `unallocated_phone_number`, `unknown`, `network_failure`, `voicemail_detected`, `user_unreachable`, `destination_forbidden`, `system_failure`, `system_at_capacity`, `insufficient_balance`, `agent_not_found`, `sip_auth_failed`, `sip_trunk_unreachable`, `spend_cap_reached`, `dnc_blocked`."
                    },
                    "postcallanalysis": {
                      "type": "object",
                      "nullable": true,
                      "additionalProperties": true,
                      "description": "Post-call analysis fields extracted for this call, keyed by field name. An empty object until analysis has run."
                    },
                    "llm_name": {
                      "type": "string",
                      "nullable": true,
                      "example": "gpt-4o",
                      "description": "Display name of the language model used on the call."
                    },
                    "voice_model_name": {
                      "type": "string",
                      "nullable": true,
                      "description": "Display name of the voice used on the call."
                    },
                    "recording_sas_url": {
                      "type": "string",
                      "format": "uri",
                      "description": "Time-limited URL for the call recording; null when the call has no recording. Request the call again for a fresh URL after it expires.",
                      "nullable": true
                    }
                  },
                  "required": [
                    "id"
                  ]
                },
                "examples": {
                  "success": {
                    "summary": "Successful response",
                    "value": {
                      "id": "call_abc123",
                      "agent_id": "agent_2g7Xy3tY53gRlp",
                      "to_number": "+919876543210",
                      "duration": "42",
                      "status": "completed",
                      "end_reason": "user_disconnected"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FilteredErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "401 Unauthorized",
                    "value": {
                      "message": "API key is missing or invalid. You can generate this by logging in into dashboard"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Call not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FilteredErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "404 Not Found",
                    "value": {
                      "message": "Call log with ID 2g7Xy3tY53gRlp not found or is deleted"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FilteredErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "500 Internal Server Error",
                    "value": {
                      "message": "An unexpected error occurred. Please try again later."
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "summary": "Get Call Details",
        "tags": [
          "Calls"
        ],
        "description": "Returns the current call record: routing, status, timing, end reason, post-call analysis and the recording URL when available. `from_number` and `to_number` are the numbers that placed and received the call, and `call_direction` is `inbound` or `outbound`."
      }
    },
    "/v1/knowledge-base": {
      "post": {
        "operationId": "createKnowledgeBase",
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateKnowledgeBaseRequest"
              },
              "examples": {
                "request": {
                  "summary": "Request example",
                  "value": {
                    "name": "Product Documentation"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Knowledge base created successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "error",
                    "statusCode",
                    "message",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "statusCode": {
                      "type": "integer",
                      "example": 201
                    },
                    "message": {
                      "type": "string",
                      "example": "Success"
                    },
                    "data": {
                      "$ref": "#/components/schemas/KnowledgeBase"
                    },
                    "timestamp": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                },
                "examples": {
                  "success": {
                    "summary": "Successful response",
                    "value": {
                      "success": true,
                      "error": false,
                      "statusCode": 201,
                      "message": "Success",
                      "data": {
                        "id": "kb_abc123",
                        "name": "Loan FAQ",
                        "org_id": "o14XKPP84rt22g",
                        "is_deleted": false,
                        "created_at": "2026-07-03T10:30:00.000Z",
                        "updated_at": "2026-07-03T10:45:00.000Z"
                      },
                      "timestamp": "2026-09-07T06:00:00.000Z"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "401 Unauthorized",
                    "value": {
                      "statusCode": 401,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Invalid API key",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Knowledge base name already exists.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "409 Conflict",
                    "value": {
                      "statusCode": 409,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "A knowledge base named \"Support FAQ\" already exists in this workspace",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request body, for example a blank name or one over 150 characters.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "400 Bad Request",
                    "value": {
                      "statusCode": 400,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "name must not be blank",
                      "errors": [
                        "name must not be blank"
                      ]
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "500 Internal Server Error",
                    "value": {
                      "statusCode": 500,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Internal server error",
                      "errors": []
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "summary": "Create Knowledge Base",
        "tags": [
          "Knowledge Base"
        ],
        "description": "Creates an empty knowledge base that can be populated and attached to agent versions."
      },
      "get": {
        "operationId": "listKnowledgeBases",
        "parameters": [
          {
            "name": "page",
            "required": false,
            "in": "query",
            "description": "Page number, starting at 1. Must be a whole number; 0 is treated as 1.",
            "schema": {
              "type": "integer",
              "default": 1,
              "example": 1
            }
          },
          {
            "name": "limit",
            "required": false,
            "in": "query",
            "description": "Knowledge bases per page. Must be a whole number. Default 20; 0 returns 50 per page, values above 100 are treated as 100, and a negative value fails with 500.",
            "schema": {
              "type": "integer",
              "default": 20,
              "example": 20
            }
          },
          {
            "name": "sortBy",
            "required": false,
            "in": "query",
            "description": "Column to sort by: id, name, org_id, is_deleted, created_at or updated_at. Default id. Any other value fails with 500.",
            "schema": {
              "type": "string",
              "default": "id",
              "example": "id"
            }
          },
          {
            "name": "sortOrder",
            "required": false,
            "in": "query",
            "description": "Sort direction: ASC or DESC, in any case. Default ASC. Any other value fails with 500.",
            "schema": {
              "type": "string",
              "default": "ASC"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Knowledge bases returned successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "error",
                    "statusCode",
                    "message",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "statusCode": {
                      "type": "integer",
                      "example": 200
                    },
                    "message": {
                      "type": "string",
                      "example": "Success"
                    },
                    "data": {
                      "type": "object",
                      "required": [
                        "items",
                        "meta"
                      ],
                      "properties": {
                        "items": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/KnowledgeBase"
                          }
                        },
                        "meta": {
                          "type": "object",
                          "required": [
                            "totalItems",
                            "itemsPerPage",
                            "totalPages",
                            "currentPage"
                          ],
                          "properties": {
                            "totalItems": {
                              "type": "integer",
                              "example": 1
                            },
                            "itemsPerPage": {
                              "type": "integer",
                              "example": 20
                            },
                            "totalPages": {
                              "type": "integer",
                              "example": 1
                            },
                            "currentPage": {
                              "type": "integer",
                              "example": 1
                            }
                          }
                        }
                      }
                    },
                    "timestamp": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                },
                "examples": {
                  "success": {
                    "summary": "Successful response",
                    "value": {
                      "success": true,
                      "error": false,
                      "statusCode": 200,
                      "message": "Success",
                      "data": {
                        "items": [
                          {
                            "id": "kb_abc123",
                            "name": "Loan FAQ",
                            "org_id": "o14XKPP84rt22g",
                            "is_deleted": false,
                            "created_at": "2026-07-03T10:30:00.000Z",
                            "updated_at": "2026-07-03T10:45:00.000Z"
                          }
                        ],
                        "meta": {
                          "totalItems": 1,
                          "itemsPerPage": 20,
                          "totalPages": 1,
                          "currentPage": 1
                        }
                      },
                      "timestamp": "2026-09-07T06:00:00.000Z"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "401 Unauthorized",
                    "value": {
                      "statusCode": 401,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Invalid API key",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "500 Internal Server Error",
                    "value": {
                      "statusCode": 500,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Internal server error",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "page or limit is a decimal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "decimal": {
                    "summary": "Decimal page",
                    "value": {
                      "statusCode": 400,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Validation failed (numeric string is expected)",
                      "errors": [
                        "Validation failed (numeric string is expected)"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "summary": "List Knowledge Bases",
        "tags": [
          "Knowledge Base"
        ],
        "description": "Returns knowledge bases for the authenticated workspace in an items and meta pagination envelope."
      }
    },
    "/v1/knowledge-base/{id}": {
      "patch": {
        "operationId": "updateKnowledgeBase",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "description": "Knowledge base ID",
            "schema": {
              "example": "kb_abc123",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateKnowledgeBaseRequest"
              },
              "examples": {
                "request": {
                  "summary": "Update a knowledge base",
                  "value": {
                    "name": "Updated Loan FAQ"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Knowledge base updated successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "error",
                    "statusCode",
                    "message",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "statusCode": {
                      "type": "integer",
                      "example": 200
                    },
                    "message": {
                      "type": "string",
                      "example": "Success"
                    },
                    "data": {
                      "$ref": "#/components/schemas/KnowledgeBase"
                    },
                    "timestamp": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                },
                "examples": {
                  "success": {
                    "summary": "Successful response",
                    "value": {
                      "success": true,
                      "error": false,
                      "statusCode": 200,
                      "message": "Success",
                      "data": {
                        "id": "kb_abc123",
                        "name": "Updated Loan FAQ",
                        "org_id": "o14XKPP84rt22g",
                        "is_deleted": false,
                        "created_at": "2026-07-03T10:30:00.000Z",
                        "updated_at": "2026-07-03T10:45:00.000Z"
                      },
                      "timestamp": "2026-09-07T06:00:00.000Z"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "New name already in use in this workspace, or the knowledge base is indexing a document.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "409 Conflict",
                    "value": {
                      "statusCode": 409,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "A knowledge base named \"Support FAQ\" already exists in this workspace",
                      "errors": []
                    }
                  },
                  "indexing": {
                    "summary": "Knowledge base is indexing",
                    "value": {
                      "statusCode": 409,
                      "error": true,
                      "success": false,
                      "data": {
                        "code": "KNOWLEDGE_BASE_INDEXING",
                        "knowledge_base_ids": [
                          "kb_Qm4TzR8wLp2VxN"
                        ]
                      },
                      "message": "This knowledge base is indexing a document. Try again in a few minutes.",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request body, for example a blank name.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "400 Bad Request",
                    "value": {
                      "statusCode": 400,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "name must not be blank",
                      "errors": [
                        "name must not be blank"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized: missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "401 Unauthorized",
                    "value": {
                      "statusCode": 401,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Invalid API key",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Knowledge base not found in this workspace.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "404 Not Found",
                    "value": {
                      "statusCode": 404,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Knowledge base with ID abc123def45678 not found",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error. A name longer than 150 characters also returns 500, with a message that starts `Error updating knowledge base:` followed by the database error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "500 Internal Server Error",
                    "value": {
                      "statusCode": 500,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Internal server error",
                      "errors": []
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "summary": "Update Knowledge Base",
        "tags": [
          "Knowledge Base"
        ],
        "description": "Renames one knowledge base without changing its ID or agent attachments. Returns 409 when another knowledge base in the workspace has the name, or while a document is being indexed."
      },
      "delete": {
        "operationId": "deleteKnowledgeBase",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "description": "Knowledge base ID",
            "schema": {
              "example": "kb_abc123",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Knowledge base deleted successfully.",
            "content": {
              "application/json": {
                "examples": {
                  "success": {
                    "summary": "Successful response",
                    "value": {
                      "success": true,
                      "error": false,
                      "statusCode": 200,
                      "message": "Success",
                      "timestamp": "2026-09-07T06:00:00.000Z"
                    }
                  }
                },
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "error",
                    "statusCode",
                    "message",
                    "timestamp"
                  ],
                  "description": "The standard envelope without a data member.",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "statusCode": {
                      "type": "integer",
                      "example": 200
                    },
                    "message": {
                      "type": "string",
                      "example": "Success"
                    },
                    "timestamp": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "401 Unauthorized",
                    "value": {
                      "statusCode": 401,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Invalid API key",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Knowledge base not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "404 Not Found",
                    "value": {
                      "statusCode": 404,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Knowledge base with ID Qm4TzR8wLp2VxN not found",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "500 Internal Server Error",
                    "value": {
                      "statusCode": 500,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Internal server error",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict. data.code KNOWLEDGE_BASE_IN_USE: agents still use the knowledge base and data.agent_ids lists them. data.code KNOWLEDGE_BASE_INDEXING: a document is still being indexed and data.knowledge_base_ids names the knowledge base; retry once it finishes.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "knowledgeBaseInUse": {
                    "summary": "409 Conflict",
                    "value": {
                      "statusCode": 409,
                      "error": true,
                      "success": false,
                      "data": {
                        "code": "KNOWLEDGE_BASE_IN_USE",
                        "agent_ids": [
                          "agent_2g7Xy3tY53gRlp"
                        ]
                      },
                      "message": "This knowledge base cannot be deleted because it is being used by 1 agent(s): agent_2g7Xy3tY53gRlp. Please unlink it from these agents before deleting.",
                      "errors": []
                    }
                  },
                  "knowledgeBaseIndexing": {
                    "summary": "Document still indexing",
                    "value": {
                      "statusCode": 409,
                      "error": true,
                      "success": false,
                      "data": {
                        "code": "KNOWLEDGE_BASE_INDEXING",
                        "knowledge_base_ids": [
                          "kb_Qm4TzR8wLp2VxN"
                        ]
                      },
                      "message": "This knowledge base is indexing a document. Try again in a few minutes.",
                      "errors": []
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "summary": "Delete Knowledge Base",
        "tags": [
          "Knowledge Base"
        ],
        "description": "Deletes a knowledge base. The request is blocked while an agent still uses it."
      },
      "get": {
        "operationId": "getKnowledgeBase",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "description": "Knowledge base ID",
            "schema": {
              "example": "kb_abc123",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Knowledge base returned successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "error",
                    "statusCode",
                    "message",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "statusCode": {
                      "type": "integer",
                      "example": 200
                    },
                    "message": {
                      "type": "string",
                      "example": "Success"
                    },
                    "data": {
                      "$ref": "#/components/schemas/KnowledgeBase"
                    },
                    "timestamp": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                },
                "examples": {
                  "success": {
                    "summary": "Successful response",
                    "value": {
                      "success": true,
                      "error": false,
                      "statusCode": 200,
                      "message": "Success",
                      "data": {
                        "id": "kb_abc123",
                        "name": "Loan FAQ",
                        "org_id": "o14XKPP84rt22g",
                        "is_deleted": false,
                        "created_at": "2026-07-03T10:30:00.000Z",
                        "updated_at": "2026-07-03T10:45:00.000Z"
                      },
                      "timestamp": "2026-09-07T06:00:00.000Z"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized: missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "401 Unauthorized",
                    "value": {
                      "statusCode": 401,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Invalid API key",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Knowledge base not found in this workspace.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "404 Not Found",
                    "value": {
                      "statusCode": 404,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Knowledge base with ID abc123def45678 not found",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "500 Internal Server Error",
                    "value": {
                      "statusCode": 500,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Internal server error",
                      "errors": []
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "summary": "Get Knowledge Base Details",
        "tags": [
          "Knowledge Base"
        ],
        "description": "Returns one knowledge base owned by the authenticated workspace."
      }
    },
    "/v1/languages": {
      "get": {
        "operationId": "listLanguages",
        "parameters": [],
        "responses": {
          "200": {
            "description": "Languages returned successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string",
                        "example": "lang_mfgsys4hhg8gdn",
                        "description": "Signed language ID"
                      },
                      "code": {
                        "type": "string",
                        "description": "Short language code, for example en, hi or hi-en.",
                        "example": "en"
                      },
                      "name": {
                        "type": "string",
                        "example": "English"
                      }
                    },
                    "required": [
                      "id"
                    ]
                  }
                },
                "examples": {
                  "success": {
                    "summary": "Successful response",
                    "value": [
                      {
                        "id": "lang_mfgsys4hhg8gdn",
                        "code": "en",
                        "name": "English"
                      },
                      {
                        "id": "lang_mfgsys4f62f0vb",
                        "code": "hi",
                        "name": "Hindi"
                      }
                    ]
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FilteredErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "401 Unauthorized",
                    "value": {
                      "message": "API key is missing or invalid. You can generate this by logging in into dashboard"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FilteredErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "500 Internal Server Error",
                    "value": {
                      "message": "An unexpected error occurred. Please try again later."
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "summary": "List Languages",
        "tags": [
          "Languages"
        ],
        "description": "Returns the global language catalog as an array of id, code, and name. Check voices and transcribers separately for language compatibility."
      }
    },
    "/v1/languages/{id}": {
      "get": {
        "operationId": "getLanguage",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "description": "Language ID",
            "schema": {
              "example": "lang_mfgsys4hhg8gdn",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Language returned successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "example": "lang_mfgsys4hhg8gdn",
                      "description": "Signed language ID"
                    },
                    "code": {
                      "type": "string",
                      "description": "Short language code, for example en, hi or hi-en.",
                      "example": "en"
                    },
                    "name": {
                      "type": "string",
                      "example": "English"
                    }
                  },
                  "required": [
                    "id"
                  ]
                },
                "examples": {
                  "success": {
                    "summary": "Successful response",
                    "value": {
                      "id": "lang_mfgsys4hhg8gdn",
                      "code": "en",
                      "name": "English"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FilteredErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "401 Unauthorized",
                    "value": {
                      "message": "API key is missing or invalid. You can generate this by logging in into dashboard"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Language not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FilteredErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "404 Not Found",
                    "value": {
                      "message": "Language with ID mfgsys4hhg8gdn not found"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FilteredErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "500 Internal Server Error",
                    "value": {
                      "message": "An unexpected error occurred. Please try again later."
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "summary": "Get Language Details",
        "tags": [
          "Languages"
        ],
        "description": "Returns id, code, and name for one language catalog entry. Its presence does not guarantee compatibility with a particular voice or transcriber."
      }
    },
    "/v1/llms": {
      "get": {
        "operationId": "listLlms",
        "parameters": [
          {
            "name": "page",
            "required": false,
            "in": "query",
            "description": "Page number, starting at 1. Must be a whole number; 0 or below is treated as 1.",
            "schema": {
              "example": 1,
              "type": "number"
            }
          },
          {
            "name": "limit",
            "required": false,
            "in": "query",
            "description": "Models per page. Must be a whole number. Default 20; 0 also returns 20, values above 100 are treated as 100, and a negative value fails with 500.",
            "schema": {
              "example": 20,
              "type": "number"
            }
          },
          {
            "name": "sortBy",
            "required": false,
            "in": "query",
            "description": "Column to sort by, for example id, name or provider. Default id. An unknown column returns 500.",
            "schema": {
              "example": "id",
              "type": "string"
            }
          },
          {
            "name": "sortOrder",
            "required": false,
            "in": "query",
            "description": "Sort direction. Default ASC.",
            "schema": {
              "enum": [
                "ASC",
                "DESC"
              ],
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "LLMs returned successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string",
                        "example": "llm_mfgt5q2x8k4w7r",
                        "description": "Signed LLM ID"
                      },
                      "name": {
                        "type": "string"
                      },
                      "provider": {
                        "enum": [
                          "google",
                          "openai",
                          "deepseek",
                          "groq",
                          "gemini",
                          "sarvam"
                        ],
                        "type": "string"
                      }
                    },
                    "required": [
                      "id"
                    ]
                  }
                },
                "examples": {
                  "success": {
                    "summary": "Successful response",
                    "value": [
                      {
                        "id": "llm_mfgt5q2x8k4w7r",
                        "name": "GPT-4.1 Mini",
                        "provider": "openai"
                      }
                    ]
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request - invalid query parameters.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FilteredErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "400 Bad Request",
                    "value": {
                      "message": "Request validation failed: Validation failed (numeric string is expected)"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FilteredErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "401 Unauthorized",
                    "value": {
                      "message": "API key is missing or invalid. You can generate this by logging in into dashboard"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FilteredErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "500 Internal Server Error",
                    "value": {
                      "message": "An unexpected error occurred. Please try again later."
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "summary": "List LLMs",
        "tags": [
          "LLMs"
        ],
        "description": "Returns one page of the language models available as an agent's primary LLM. Defaults to 20 models per page; limits above 100 are capped at 100. The API-key response is a plain array without pagination metadata."
      }
    },
    "/v1/llms/fallback": {
      "get": {
        "operationId": "listFallbackLlms",
        "parameters": [
          {
            "name": "page",
            "required": false,
            "in": "query",
            "description": "Page number, starting at 1. Must be a whole number; 0 or below is treated as 1.",
            "schema": {
              "example": 1,
              "type": "number"
            }
          },
          {
            "name": "limit",
            "required": false,
            "in": "query",
            "description": "Models per page. Must be a whole number. Default 20; 0 also returns 20, values above 100 are treated as 100, and a negative value fails with 500.",
            "schema": {
              "example": 20,
              "type": "number"
            }
          },
          {
            "name": "sortBy",
            "required": false,
            "in": "query",
            "description": "Column to sort by, for example id, name or provider. Default id. An unknown column returns 500.",
            "schema": {
              "example": "id",
              "type": "string"
            }
          },
          {
            "name": "sortOrder",
            "required": false,
            "in": "query",
            "description": "Sort direction. Default ASC.",
            "schema": {
              "enum": [
                "ASC",
                "DESC"
              ],
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Fallback LLM returned successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string",
                        "example": "llm_mfgt5q2x8k4w7r",
                        "description": "Signed LLM ID"
                      },
                      "name": {
                        "type": "string"
                      },
                      "provider": {
                        "enum": [
                          "google",
                          "openai",
                          "deepseek",
                          "groq",
                          "gemini",
                          "sarvam"
                        ],
                        "type": "string"
                      }
                    },
                    "required": [
                      "id"
                    ]
                  }
                },
                "examples": {
                  "success": {
                    "summary": "Successful response",
                    "value": [
                      {
                        "id": "llm_mh2k7w9q4x1zpt",
                        "name": "Gemini 3.1 Flash Lite",
                        "provider": "gemini"
                      }
                    ]
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request - invalid query parameters.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FilteredErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "400 Bad Request",
                    "value": {
                      "message": "Request validation failed: Validation failed (numeric string is expected)"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FilteredErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "401 Unauthorized",
                    "value": {
                      "message": "API key is missing or invalid. You can generate this by logging in into dashboard"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FilteredErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "500 Internal Server Error",
                    "value": {
                      "message": "An unexpected error occurred. Please try again later."
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "summary": "List Fallback LLMs",
        "tags": [
          "LLMs"
        ],
        "description": "Returns one page of eligible fallback language models. Defaults to 20 models per page; limits above 100 are capped at 100. The API-key response is a plain array without pagination metadata."
      }
    },
    "/v1/llms/{id}": {
      "get": {
        "operationId": "getLlm",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "description": "LLM ID",
            "schema": {
              "example": "llm_mfgt5q2x8k4w7r",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "LLM returned successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "example": "llm_mfgt5q2x8k4w7r",
                      "description": "Signed LLM ID"
                    },
                    "name": {
                      "type": "string"
                    },
                    "provider": {
                      "enum": [
                        "google",
                        "openai",
                        "deepseek",
                        "groq",
                        "gemini",
                        "sarvam"
                      ],
                      "type": "string"
                    }
                  },
                  "required": [
                    "id"
                  ]
                },
                "examples": {
                  "success": {
                    "summary": "Successful response",
                    "value": {
                      "id": "llm_mfgt5q2x8k4w7r",
                      "name": "GPT-4.1 Mini",
                      "provider": "openai"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FilteredErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "401 Unauthorized",
                    "value": {
                      "message": "API key is missing or invalid. You can generate this by logging in into dashboard"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "LLM not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FilteredErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "404 Not Found",
                    "value": {
                      "message": "Could not find LLM with id: abc12345678901"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FilteredErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "500 Internal Server Error",
                    "value": {
                      "message": "An unexpected error occurred. Please try again later."
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "summary": "Get LLM Details",
        "tags": [
          "LLMs"
        ],
        "description": "Returns one large language model catalog record by ID. It does not check primary or fallback eligibility, so a model returned here may not be accepted in that role."
      }
    },
    "/v1/organization-folders": {
      "get": {
        "operationId": "listOrganizationFolders",
        "parameters": [
          {
            "name": "search",
            "required": false,
            "in": "query",
            "description": "Search by folder name",
            "schema": {
              "example": "Call",
              "type": "string"
            }
          },
          {
            "name": "page",
            "required": false,
            "in": "query",
            "description": "Page number, starting from 1. Default 1. Read with parseInt, so 2.5 or 2abc is page 2; a value that does not start with a number, or is below 1, returns 400.",
            "schema": {
              "default": "1",
              "example": "1",
              "type": "string"
            }
          },
          {
            "name": "limit",
            "required": false,
            "in": "query",
            "description": "Folders per page, from 1 to 50. Default 20. Read with parseInt, so 10.5 is 10; a value that does not start with a number, or is outside 1 to 50, returns 400.",
            "schema": {
              "default": "20",
              "example": "20",
              "type": "string"
            }
          },
          {
            "name": "export",
            "required": false,
            "in": "query",
            "description": "Accepted for compatibility but ignored: results are always paginated.",
            "schema": {
              "default": false,
              "example": true,
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Organization folders returned successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "error",
                    "statusCode",
                    "message",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "statusCode": {
                      "type": "integer",
                      "example": 200
                    },
                    "message": {
                      "type": "string",
                      "example": "Success"
                    },
                    "data": {
                      "type": "object",
                      "required": [
                        "folders",
                        "page",
                        "limit"
                      ],
                      "properties": {
                        "folders": {
                          "type": "array",
                          "items": {
                            "allOf": [
                              {
                                "$ref": "#/components/schemas/OrganizationFolder"
                              },
                              {
                                "type": "object",
                                "required": [
                                  "agentCount"
                                ],
                                "properties": {
                                  "agentCount": {
                                    "type": "integer",
                                    "example": 3,
                                    "description": "Number of agents in the folder that are not deleted. Returned by the list only, not by Get Organization Folder."
                                  }
                                }
                              }
                            ]
                          }
                        },
                        "page": {
                          "type": "integer",
                          "example": 1
                        },
                        "limit": {
                          "type": "integer",
                          "example": 20
                        }
                      }
                    },
                    "timestamp": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                },
                "examples": {
                  "success": {
                    "summary": "Successful response",
                    "value": {
                      "success": true,
                      "error": false,
                      "statusCode": 200,
                      "message": "Success",
                      "data": {
                        "folders": [
                          {
                            "id": "f5k2m8x1q9w3zp",
                            "organization_id": "o14XKPP84rt22g",
                            "name": "Sales Agents",
                            "is_deleted": false,
                            "createdAt": "2026-07-03T10:30:00.000Z",
                            "updatedAt": "2026-07-03T10:30:00.000Z",
                            "organization": {
                              "id": "o14XKPP84rt22g",
                              "title": "Acme Lending"
                            },
                            "agentCount": 3
                          }
                        ],
                        "page": 1,
                        "limit": 20
                      },
                      "timestamp": "2026-09-07T06:00:00.000Z"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "401 Unauthorized",
                    "value": {
                      "statusCode": 401,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Invalid API key",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Authenticated organization not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "404 Not Found",
                    "value": {
                      "statusCode": 404,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Organization with ID o14XKPP84rt22g not found",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "500 Internal Server Error",
                    "value": {
                      "statusCode": 500,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Internal server error",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "page or limit is out of range.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "400 Bad Request",
                    "value": {
                      "statusCode": 400,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Limit must be between 1 and 50",
                      "errors": []
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "summary": "List Organization Folders",
        "tags": [
          "Organization Folders"
        ],
        "description": "Returns active folders for the authenticated organization with optional search and pagination."
      }
    },
    "/v1/organization-folders/{id}": {
      "get": {
        "operationId": "getOrganizationFolder",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "description": "ID of the folder",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Organization folder returned successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "error",
                    "statusCode",
                    "message",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "statusCode": {
                      "type": "integer",
                      "example": 200
                    },
                    "message": {
                      "type": "string",
                      "example": "Success"
                    },
                    "data": {
                      "$ref": "#/components/schemas/OrganizationFolder"
                    },
                    "timestamp": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                },
                "examples": {
                  "success": {
                    "summary": "Successful response",
                    "value": {
                      "success": true,
                      "error": false,
                      "statusCode": 200,
                      "message": "Success",
                      "data": {
                        "id": "f5k2m8x1q9w3zp",
                        "organization_id": "o14XKPP84rt22g",
                        "name": "Sales Agents",
                        "is_deleted": false,
                        "createdAt": "2026-07-03T10:30:00.000Z",
                        "updatedAt": "2026-07-03T10:30:00.000Z",
                        "organization": {
                          "id": "o14XKPP84rt22g",
                          "title": "Acme Lending"
                        }
                      },
                      "timestamp": "2026-09-07T06:00:00.000Z"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "401 Unauthorized",
                    "value": {
                      "statusCode": 401,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Invalid API key",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Folder not found in the authenticated organization.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "404 Not Found",
                    "value": {
                      "statusCode": 404,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Folder with ID f5k2m8x1q9w3zp not found for organization ID: o14XKPP84rt22g",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "500 Internal Server Error",
                    "value": {
                      "statusCode": 500,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Internal server error",
                      "errors": []
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "summary": "Get Organization Folder",
        "tags": [
          "Organization Folders"
        ],
        "description": "Returns one active organization folder by ID."
      }
    },
    "/v1/phone-country-rules/countries": {
      "get": {
        "operationId": "listPhoneCountryRules",
        "responses": {
          "200": {
            "description": "Active phone country rules returned successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "error",
                    "statusCode",
                    "message",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "statusCode": {
                      "type": "integer",
                      "example": 200
                    },
                    "message": {
                      "type": "string",
                      "example": "Success"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/PhoneCountryRule"
                      }
                    },
                    "timestamp": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "summary": "List Phone Country Rules",
        "tags": [
          "Phone Numbers"
        ],
        "description": "Returns the active global country catalog with calling codes, number lengths, and prefixes."
      }
    },
    "/v1/phone-country-rules/enabled-network-groups": {
      "get": {
        "operationId": "listEnabledTelephonyNetworkGroups",
        "responses": {
          "200": {
            "description": "Enabled destination rules returned successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "error",
                    "statusCode",
                    "message",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "statusCode": {
                      "type": "integer",
                      "example": 200
                    },
                    "message": {
                      "type": "string",
                      "example": "Success"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/EnabledTelephonyNetworkGroup"
                      }
                    },
                    "timestamp": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "summary": "List Enabled Telephony Network Groups",
        "tags": [
          "Phone Numbers"
        ],
        "description": "Returns one combined destination rule per country enabled for the authenticated workspace.",
        "parameters": []
      }
    },
    "/v1/phone-number-pricing": {
      "get": {
        "operationId": "listPhoneNumberPricing",
        "responses": {
          "200": {
            "description": "Phone number pricing returned successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "error",
                    "statusCode",
                    "message",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "statusCode": {
                      "type": "integer",
                      "example": 200
                    },
                    "message": {
                      "type": "string",
                      "example": "Success"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/PhoneNumberPricing"
                      }
                    },
                    "timestamp": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "summary": "List Phone Number Pricing",
        "tags": [
          "Phone Numbers"
        ],
        "description": "Returns the phone number rental pricing reference catalog by telephony provider and country. A purchase is charged the rental rate in the workspace billing plan, not this credit_cost."
      }
    },
    "/v1/organization-phone-numbers": {
      "get": {
        "operationId": "listPhoneNumbers",
        "parameters": [
          {
            "name": "page",
            "required": false,
            "in": "query",
            "description": "Page number, starting from 1.",
            "schema": {
              "minimum": 1,
              "default": 1,
              "type": "number"
            }
          },
          {
            "name": "limit",
            "required": false,
            "in": "query",
            "description": "Results per page.",
            "schema": {
              "minimum": 1,
              "default": 20,
              "type": "number"
            }
          },
          {
            "name": "sortBy",
            "required": false,
            "in": "query",
            "description": "Field to sort by.",
            "schema": {
              "default": "id",
              "type": "string",
              "enum": [
                "id",
                "created_at",
                "updated_at",
                "status"
              ]
            }
          },
          {
            "name": "sortOrder",
            "required": false,
            "in": "query",
            "description": "Sort direction.",
            "schema": {
              "default": "ASC",
              "type": "string",
              "enum": [
                "ASC",
                "DESC"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Phone numbers returned successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "error",
                    "statusCode",
                    "message",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "statusCode": {
                      "type": "integer",
                      "example": 200
                    },
                    "message": {
                      "type": "string",
                      "example": "Success"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "items": {
                          "type": "array",
                          "items": {
                            "allOf": [
                              {
                                "$ref": "#/components/schemas/PhoneNumberRecord"
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "is_default": {
                                    "type": "boolean",
                                    "description": "Whether this is a DialNexa system default number. List rows only."
                                  }
                                }
                              }
                            ]
                          }
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "currentPage": {
                              "type": "integer",
                              "example": 1
                            },
                            "itemsPerPage": {
                              "type": "integer",
                              "example": 20
                            },
                            "hasMore": {
                              "type": "boolean",
                              "description": "True when a further page exists. No total is returned."
                            }
                          }
                        }
                      }
                    },
                    "timestamp": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                },
                "examples": {
                  "success": {
                    "summary": "Successful response",
                    "value": {
                      "success": true,
                      "error": false,
                      "statusCode": 200,
                      "message": "Success",
                      "data": {
                        "items": [
                          {
                            "id": "phn_mfk3p8z2c4v6bn",
                            "phone_number": "9876543210",
                            "status": "active",
                            "country_iso": "91",
                            "telephony_provider_id": "mh00mke5j83neo",
                            "organization_id": "o14XKPP84rt22g",
                            "inbound_agent_id": null,
                            "outbound_agent_id": "agent_2g7Xy3tY53gRlp",
                            "rental_start_date": "2026-09-17",
                            "rental_end_date": "2026-10-17",
                            "rental_status": "active",
                            "sip_trunk_enabled": false,
                            "nickname": null,
                            "is_deleted": false,
                            "deleted_at": null,
                            "deleted_by": null,
                            "created_at": "2026-09-17T05:52:18.634Z",
                            "updated_at": "2026-09-17T05:52:18.634Z",
                            "is_default": true
                          }
                        ],
                        "meta": {
                          "currentPage": 1,
                          "itemsPerPage": 20,
                          "hasMore": false
                        }
                      },
                      "timestamp": "2026-09-07T06:00:00.000Z"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "401 Unauthorized",
                    "value": {
                      "statusCode": 401,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Invalid API key",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "500 Internal Server Error",
                    "value": {
                      "statusCode": 500,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Internal server error",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "page or limit is below 1 or not a whole number, or sortBy or sortOrder is outside its allowed values.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "limit": {
                    "summary": "limit below 1",
                    "value": {
                      "statusCode": 400,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "limit must not be less than 1",
                      "errors": [
                        "limit must not be less than 1"
                      ]
                    }
                  },
                  "sortOrder": {
                    "summary": "Unknown sortOrder",
                    "value": {
                      "statusCode": 400,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "sortOrder must be one of the following values: ASC, DESC",
                      "errors": [
                        "sortOrder must be one of the following values: ASC, DESC"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "summary": "List Phone Numbers",
        "tags": [
          "Phone Numbers"
        ],
        "description": "Returns phone numbers owned by the authenticated workspace with pagination metadata."
      }
    },
    "/v1/organization-phone-numbers/plivo-numbers": {
      "get": {
        "description": "Searches available Plivo phone numbers that match the supplied filters. The response is Plivo's own search result, passed through unchanged.",
        "operationId": "searchAvailablePhoneNumbers",
        "parameters": [
          {
            "name": "country_iso",
            "required": true,
            "in": "query",
            "description": "ISO country code (e.g., IN, US, GB)",
            "schema": {
              "example": "IN",
              "type": "string"
            }
          },
          {
            "name": "type",
            "required": false,
            "in": "query",
            "description": "Number type: local, tollfree, or mobile. Defaults to tollfree.",
            "schema": {
              "example": "tollfree",
              "type": "string",
              "default": "tollfree"
            }
          },
          {
            "name": "region",
            "required": false,
            "in": "query",
            "description": "City or state filter. For IN it is sent to Plivo as city (for example Mumbai, Bengaluru, Chennai). For Mumbai and Bengaluru (or Bangalore) only, a city search that returns no numbers is retried with the city's STD code as a number pattern. For other countries it is sent as region (for example California, Texas).",
            "schema": {
              "example": "Mumbai",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Available Plivo numbers returned successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "error",
                    "statusCode",
                    "message",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "statusCode": {
                      "type": "integer",
                      "example": 200
                    },
                    "message": {
                      "type": "string",
                      "example": "Success"
                    },
                    "data": {
                      "$ref": "#/components/schemas/AvailablePhoneNumbersResponse"
                    },
                    "timestamp": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                },
                "examples": {
                  "success": {
                    "summary": "Successful response",
                    "value": {
                      "success": true,
                      "error": false,
                      "statusCode": 200,
                      "message": "Success",
                      "data": {
                        "api_id": "9f6d7c",
                        "objects": [
                          {
                            "number": "14155552671",
                            "type": "local",
                            "monthly_rental_rate": "0.80",
                            "setup_rate": "0.00",
                            "voice_enabled": true,
                            "sms_enabled": true,
                            "mms_enabled": false,
                            "country_iso": "US",
                            "number_format": "14155552671"
                          }
                        ],
                        "meta": {
                          "total_count": 1
                        }
                      },
                      "timestamp": "2026-09-07T06:00:00.000Z"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Plivo rejected the number search. The message starts with \"Failed to fetch phone numbers from Plivo: \" followed by Plivo's error, and the status code is Plivo's own, so other 4xx codes are possible.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "401 Unauthorized",
                    "value": {
                      "statusCode": 401,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Invalid API key",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "500 Internal Server Error",
                    "value": {
                      "statusCode": 500,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Internal server error",
                      "errors": []
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "summary": "Search Plivo Numbers",
        "tags": [
          "Phone Numbers"
        ]
      }
    },
    "/v1/organization-phone-numbers/purchase": {
      "post": {
        "description": "Purchases the selected provider number (Plivo or Twilio, chosen by telephonyProviderId) and adds it to the authenticated workspace. The workspace KYC must be verified, and a Plivo number in IN needs a compliance ID mapped to the workspace by support. On a workspace with a billing plan, the wallet must hold the plan's rental rate for the provider and country; the first cycle is charged just after the number is set up.",
        "operationId": "purchasePhoneNumber",
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PurchasePhoneNumberRequest"
              },
              "examples": {
                "request": {
                  "summary": "Purchase a phone number",
                  "value": {
                    "phoneNumber": "14155552671",
                    "telephonyProviderId": "mh00mke5j83neo",
                    "countryISO": "US"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "400": {
            "description": "Invalid request body, unsupported telephonyProviderId, organization KYC not verified, no compliance ID mapped for an IN Plivo number, phone number rental not configured for the billing plan, insufficient wallet balance, the first rental would go over the monthly spend cap, or the number was bought but could not be set up.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "400 Bad Request",
                    "value": {
                      "statusCode": 400,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "countryISO must be a 2-letter uppercase ISO code (e.g., US, IN)",
                      "errors": [
                        "countryISO must be a 2-letter uppercase ISO code (e.g., US, IN)"
                      ]
                    }
                  },
                  "spendCap": {
                    "summary": "Monthly spend cap",
                    "value": {
                      "statusCode": 400,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "This purchase (₹500.00) would go over your monthly spend cap. Raise the cap in Billing → Balance alerts, or try again after the 1st.",
                      "errors": [
                        "This purchase (₹500.00) would go over your monthly spend cap. Raise the cap in Billing → Balance alerts, or try again after the 1st."
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "401 Unauthorized",
                    "value": {
                      "statusCode": 401,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Invalid API key",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "500 Internal Server Error",
                    "value": {
                      "statusCode": 500,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Error purchasing phone number: Invalid phone number or ISO code",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "201": {
            "description": "Purchase processed. Inspect the active or pending status and confirm the saved number before routing calls.",
            "content": {
              "application/json": {
                "examples": {
                  "success": {
                    "summary": "Successful response",
                    "value": {
                      "success": true,
                      "error": false,
                      "statusCode": 201,
                      "message": "Success",
                      "data": {
                        "phoneNumber": "14155552671",
                        "status": "active",
                        "message": "Phone number 14155552671 purchase request sent.",
                        "organizationPhoneNumber": {
                          "id": "phn_mfk3p8z2c4v6bn",
                          "phone_number": "4155552671",
                          "status": "pending",
                          "country_iso": "1",
                          "telephony_provider_id": "mh00mke5j83neo",
                          "organization_id": "o14XKPP84rt22g",
                          "inbound_agent_id": null,
                          "outbound_agent_id": null,
                          "rental_start_date": null,
                          "rental_end_date": null,
                          "rental_status": null,
                          "sip_trunk_enabled": false,
                          "nickname": null,
                          "is_deleted": false,
                          "deleted_at": null,
                          "deleted_by": null,
                          "created_at": "2026-09-17T05:52:18.634Z",
                          "updated_at": "2026-09-17T05:52:18.634Z"
                        }
                      },
                      "timestamp": "2026-09-07T06:00:00.000Z"
                    }
                  }
                },
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "error",
                    "statusCode",
                    "message",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "statusCode": {
                      "type": "integer",
                      "example": 201
                    },
                    "message": {
                      "type": "string",
                      "example": "Success"
                    },
                    "data": {
                      "type": "object",
                      "required": [
                        "phoneNumber",
                        "status",
                        "message"
                      ],
                      "properties": {
                        "phoneNumber": {
                          "type": "string",
                          "description": "The number as sent in the request."
                        },
                        "status": {
                          "type": "string",
                          "enum": [
                            "active",
                            "pending"
                          ],
                          "description": "Provider purchase status. pending means the provider is still verifying the number."
                        },
                        "message": {
                          "type": "string",
                          "example": "Phone number 14155552671 purchase request sent."
                        },
                        "organizationPhoneNumber": {
                          "allOf": [
                            {
                              "$ref": "#/components/schemas/PhoneNumberRecord"
                            }
                          ],
                          "description": "The workspace phone number record as created. Its status is the stored default (pending) at creation; read the number again for its current status and rental dates."
                        }
                      }
                    },
                    "timestamp": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "summary": "Buy Phone Number",
        "tags": [
          "Phone Numbers"
        ]
      }
    },
    "/v1/organization-phone-numbers/sip-trunks": {
      "post": {
        "operationId": "linkSipTrunk",
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LinkSipTrunkRequest"
              },
              "examples": {
                "request": {
                  "summary": "Link a SIP trunk",
                  "value": {
                    "phoneNumber": "+14155552671",
                    "terminationUri": "31974861099010243.zt.plivo.com:5060",
                    "authMode": "userpass",
                    "sipTrunkUserName": "sip-user",
                    "sipTrunkPassword": "YOUR_SIP_PASSWORD",
                    "nickname": "US BYOC Line"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "SIP trunk linked successfully.",
            "content": {
              "application/json": {
                "examples": {
                  "success": {
                    "summary": "Successful response",
                    "value": {
                      "success": true,
                      "error": false,
                      "statusCode": 201,
                      "message": "Success",
                      "data": {
                        "id": "phn_mfk3p8z2c4v6bn",
                        "country_iso": "1",
                        "phone_number": 4155552671,
                        "termination_uri": "31974861099010243.zt.plivo.com:5060",
                        "sip_trunk_enabled": true,
                        "nickname": "US BYOC Line",
                        "auth_mode": "userpass",
                        "sip_username": "sip-user"
                      },
                      "timestamp": "2026-09-07T06:00:00.000Z"
                    }
                  }
                },
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "error",
                    "statusCode",
                    "message",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "statusCode": {
                      "type": "integer",
                      "example": 201
                    },
                    "message": {
                      "type": "string",
                      "example": "Success"
                    },
                    "data": {
                      "type": "object",
                      "required": [
                        "id",
                        "country_iso",
                        "phone_number",
                        "termination_uri",
                        "sip_trunk_enabled",
                        "nickname",
                        "auth_mode",
                        "sip_username"
                      ],
                      "properties": {
                        "id": {
                          "type": "string",
                          "example": "phn_mfk3p8z2c4v6bn",
                          "description": "Signed phone number ID."
                        },
                        "country_iso": {
                          "type": "string",
                          "example": "1",
                          "description": "Country calling code without the plus sign."
                        },
                        "phone_number": {
                          "type": "integer",
                          "format": "int64",
                          "example": 4155552671,
                          "description": "National number without the calling code, as a JSON number."
                        },
                        "termination_uri": {
                          "type": "string",
                          "example": "31974861099010243.zt.plivo.com:5060"
                        },
                        "sip_trunk_enabled": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "nickname": {
                          "type": "string",
                          "nullable": true
                        },
                        "auth_mode": {
                          "type": "string",
                          "enum": [
                            "userpass",
                            "ip"
                          ]
                        },
                        "sip_username": {
                          "type": "string",
                          "nullable": true,
                          "description": "null for authMode ip."
                        }
                      }
                    },
                    "timestamp": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid number, termination host, authentication mode, or credential combination.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "400 Bad Request",
                    "value": {
                      "statusCode": 400,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "sipTrunkUserName and sipTrunkPassword are required when authMode is userpass",
                      "errors": [
                        "sipTrunkUserName and sipTrunkPassword are required when authMode is userpass"
                      ]
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Phone number already registered",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "409 Conflict",
                    "value": {
                      "statusCode": 409,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "This phone number is already registered for your organization",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "502": {
            "description": "SIP trunk registration failed. Nothing is saved; retry or contact support.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "401 Unauthorized",
                    "value": {
                      "statusCode": 401,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Invalid API key",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "500 Internal Server Error",
                    "value": {
                      "statusCode": 500,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Internal server error",
                      "errors": []
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "summary": "Link SIP Trunk",
        "tags": [
          "Phone Numbers"
        ],
        "description": "Registers a bring-your-own number with SIP trunk credentials for workspace routing."
      }
    },
    "/v1/organization-phone-numbers/{id}": {
      "delete": {
        "description": "Deletes a workspace phone number, releases its provider rental or SIP connection, unlinks it from its agents, and prevents future DialNexa routing. The request is blocked if the number is a system default, has live calls, is used by a batch that is running, paused, scheduled or waiting, or is used by an active workflow. If the provider rental or SIP trunk cannot be released, the request fails with 502 and the number is kept.",
        "operationId": "deletePhoneNumber",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "description": "Phone number ID",
            "schema": {
              "example": "phn_mfk3p8z2c4v6bn",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Phone number deleted successfully. data is the number 200.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "error",
                    "statusCode",
                    "message",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "statusCode": {
                      "type": "integer",
                      "example": 200
                    },
                    "message": {
                      "type": "string",
                      "example": "Success"
                    },
                    "data": {
                      "type": "integer",
                      "enum": [
                        200
                      ]
                    },
                    "timestamp": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                },
                "examples": {
                  "success": {
                    "summary": "Successful response",
                    "value": {
                      "success": true,
                      "error": false,
                      "statusCode": 200,
                      "message": "Success",
                      "data": 200,
                      "timestamp": "2026-09-07T06:00:00.000Z"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid API key."
          },
          "404": {
            "description": "Phone number not found."
          },
          "409": {
            "description": "Conflict: the number is a system default, has live calls (PHONE_NUMBER_HAS_LIVE_CALLS), is used by a batch that is running, paused, scheduled or waiting (NUMBER_USED_BY_BATCH), or is used by an active workflow (PHONE_NUMBER_USED_IN_ACTIVE_WORKFLOWS).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "numberUsedByBatch": {
                    "summary": "Number used by an unfinished batch",
                    "value": {
                      "statusCode": 409,
                      "error": true,
                      "success": false,
                      "data": {
                        "code": "NUMBER_USED_BY_BATCH",
                        "batches": [
                          {
                            "id": "batch_mfh2k9x7q1w3er",
                            "title": "July renewals",
                            "status": "running"
                          }
                        ],
                        "live_calls": 0
                      },
                      "message": "1 unfinished batch(es) (\"July renewals\") and 0 live call(s) use this number. Change the batches' number or cancel them first.",
                      "errors": []
                    }
                  },
                  "phoneNumberHasLiveCalls": {
                    "summary": "Calls in progress on the number",
                    "value": {
                      "statusCode": 409,
                      "error": true,
                      "success": false,
                      "data": {
                        "code": "PHONE_NUMBER_HAS_LIVE_CALLS",
                        "live_calls": 2,
                        "batches": []
                      },
                      "message": "2 call(s) are in progress on this number. Wait for them to finish, then retry.",
                      "errors": []
                    }
                  },
                  "phoneNumberUsedInActiveWorkflows": {
                    "summary": "Number used by an active workflow",
                    "value": {
                      "statusCode": 409,
                      "error": true,
                      "success": false,
                      "data": {
                        "code": "PHONE_NUMBER_USED_IN_ACTIVE_WORKFLOWS",
                        "affected_workflows": [
                          {
                            "id": "mfk3p8z2c4v6bn",
                            "title": "Lead follow-up",
                            "status": "active"
                          }
                        ]
                      },
                      "message": "This phone number is used in 1 active workflow(s). Pause those workflows first, then retry.",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error."
          },
          "502": {
            "description": "The telephony provider did not release the number, the provider does not support release, or DialNexa could not remove the SIP trunk. The number is not deleted.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "providerReleaseFailed": {
                    "summary": "Provider release failed",
                    "value": {
                      "statusCode": 502,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Could not release the phone number with the telephony provider. Try again or contact support.",
                      "errors": []
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "summary": "Delete Phone Number",
        "tags": [
          "Phone Numbers"
        ]
      },
      "get": {
        "operationId": "getPhoneNumber",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "description": "Phone number ID",
            "schema": {
              "example": "phn_mfk3p8z2c4v6bn",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Phone number returned successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "error",
                    "statusCode",
                    "message",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "statusCode": {
                      "type": "integer",
                      "example": 200
                    },
                    "message": {
                      "type": "string",
                      "example": "Success"
                    },
                    "data": {
                      "$ref": "#/components/schemas/PhoneNumberRecord"
                    },
                    "timestamp": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                },
                "examples": {
                  "success": {
                    "summary": "Successful response",
                    "value": {
                      "success": true,
                      "error": false,
                      "statusCode": 200,
                      "message": "Success",
                      "data": {
                        "id": "phn_mfk3p8z2c4v6bn",
                        "phone_number": "9876543210",
                        "status": "active",
                        "country_iso": "91",
                        "telephony_provider_id": "mh00mke5j83neo",
                        "organization_id": "o14XKPP84rt22g",
                        "inbound_agent_id": null,
                        "outbound_agent_id": "agent_2g7Xy3tY53gRlp",
                        "rental_start_date": "2026-09-17",
                        "rental_end_date": "2026-10-17",
                        "rental_status": "active",
                        "sip_trunk_enabled": false,
                        "nickname": null,
                        "is_deleted": false,
                        "deleted_at": null,
                        "deleted_by": null,
                        "created_at": "2026-09-17T05:52:18.634Z",
                        "updated_at": "2026-09-17T05:52:18.634Z"
                      },
                      "timestamp": "2026-09-07T06:00:00.000Z"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "401 Unauthorized",
                    "value": {
                      "statusCode": 401,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Invalid API key",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Phone number not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "404 Not Found",
                    "value": {
                      "statusCode": 404,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Failed to fetch phone number: Phone number not found or does not belong to your organization",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "500 Internal Server Error",
                    "value": {
                      "statusCode": 500,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Internal server error",
                      "errors": []
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "summary": "Get Phone Number Details",
        "tags": [
          "Phone Numbers"
        ],
        "description": "Returns one workspace phone number and its routing configuration."
      }
    },
    "/v1/transcribers": {
      "get": {
        "operationId": "listTranscribers",
        "parameters": [],
        "responses": {
          "200": {
            "description": "Transcribers returned successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "error",
                    "statusCode",
                    "message",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "statusCode": {
                      "type": "integer",
                      "example": 200
                    },
                    "message": {
                      "type": "string",
                      "example": "Success"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Transcriber"
                      }
                    },
                    "timestamp": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                },
                "examples": {
                  "success": {
                    "summary": "Successful response",
                    "value": {
                      "success": true,
                      "error": false,
                      "statusCode": 200,
                      "message": "Success",
                      "data": [
                        {
                          "id": "trs_tr0soniox001xx",
                          "provider": "soniox",
                          "model_id": "stt-rt-v5",
                          "name": "Soniox STT RT v5",
                          "description": "Soniox real-time speech-to-text model v5.",
                          "supported_language_codes": null,
                          "provider_model_id": "pmd_798b2e5834",
                          "is_primary": true,
                          "is_fallback": true,
                          "is_deleted": false,
                          "createdAt": "2026-03-01T00:00:00.000Z",
                          "updatedAt": "2026-03-01T00:00:00.000Z"
                        }
                      ],
                      "timestamp": "2026-09-07T06:00:00.000Z"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "401 Unauthorized",
                    "value": {
                      "statusCode": 401,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Invalid API key",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "500 Internal Server Error",
                    "value": {
                      "statusCode": 500,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Internal server error",
                      "errors": []
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "summary": "List Transcribers",
        "tags": [
          "Transcribers"
        ],
        "description": "Returns the speech-to-text transcribers that can be an agent's primary transcriber. Use List Fallback Transcribers for fallback choices."
      }
    },
    "/v1/transcribers/fallback": {
      "get": {
        "description": "Returns all transcribers eligible for use as a fallback STT provider. Use this list to populate the Fallback STT selector when configuring per-agent STT fallback settings.",
        "operationId": "listFallbackTranscribers",
        "parameters": [],
        "responses": {
          "200": {
            "description": "Fallback-eligible transcribers returned successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "error",
                    "statusCode",
                    "message",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "statusCode": {
                      "type": "integer",
                      "example": 200
                    },
                    "message": {
                      "type": "string",
                      "example": "Success"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Transcriber"
                      }
                    },
                    "timestamp": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                },
                "examples": {
                  "success": {
                    "summary": "Successful response",
                    "value": {
                      "success": true,
                      "error": false,
                      "statusCode": 200,
                      "message": "Success",
                      "data": [
                        {
                          "id": "trs_tr0soniox001xx",
                          "provider": "soniox",
                          "model_id": "stt-rt-v5",
                          "name": "Soniox STT RT v5",
                          "description": "Soniox real-time speech-to-text model v5.",
                          "supported_language_codes": null,
                          "provider_model_id": "pmd_798b2e5834",
                          "is_primary": true,
                          "is_fallback": true,
                          "is_deleted": false,
                          "createdAt": "2026-03-01T00:00:00.000Z",
                          "updatedAt": "2026-03-01T00:00:00.000Z"
                        }
                      ],
                      "timestamp": "2026-09-07T06:00:00.000Z"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "401 Unauthorized",
                    "value": {
                      "statusCode": 401,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Invalid API key",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "500 Internal Server Error",
                    "value": {
                      "statusCode": 500,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Internal server error",
                      "errors": []
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "summary": "List Fallback Transcribers",
        "tags": [
          "Transcribers"
        ]
      }
    },
    "/v1/transcribers/{id}": {
      "get": {
        "operationId": "getTranscriber",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "description": "Transcriber ID",
            "schema": {
              "example": "trs_tr0soniox001xx",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Transcriber returned successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "error",
                    "statusCode",
                    "message",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "statusCode": {
                      "type": "integer",
                      "example": 200
                    },
                    "message": {
                      "type": "string",
                      "example": "Success"
                    },
                    "data": {
                      "$ref": "#/components/schemas/Transcriber"
                    },
                    "timestamp": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                },
                "examples": {
                  "success": {
                    "summary": "Successful response",
                    "value": {
                      "success": true,
                      "error": false,
                      "statusCode": 200,
                      "message": "Success",
                      "data": {
                        "id": "trs_tr0soniox001xx",
                        "provider": "soniox",
                        "model_id": "stt-rt-v5",
                        "name": "Soniox STT RT v5",
                        "description": "Soniox real-time speech-to-text model v5.",
                        "supported_language_codes": null,
                        "provider_model_id": "pmd_798b2e5834",
                        "is_primary": true,
                        "is_fallback": true,
                        "is_deleted": false,
                        "createdAt": "2026-03-01T00:00:00.000Z",
                        "updatedAt": "2026-03-01T00:00:00.000Z"
                      },
                      "timestamp": "2026-09-07T06:00:00.000Z"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "401 Unauthorized",
                    "value": {
                      "statusCode": 401,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Invalid API key",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Transcriber not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "404 Not Found",
                    "value": {
                      "statusCode": 404,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Transcriber tr0deepnova3xx not found",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "500 Internal Server Error",
                    "value": {
                      "statusCode": 500,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Internal server error",
                      "errors": []
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "summary": "Get Transcriber Details",
        "tags": [
          "Transcribers"
        ],
        "description": "Returns one speech-to-text transcriber catalog record by ID."
      }
    },
    "/v1/user-webhooks": {
      "post": {
        "description": "Registers a webhook URL for your workspace. The response is the only one that returns the plain secret; store it securely. DialNexa sends one signed POST when a call that was not started by a batch call ends, with no retry and no timeout. The x-nexa-signature header is sha256=<hex>, an HMAC-SHA256 of the raw request body with your secret.",
        "operationId": "createWebhook",
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateWebhookRequest"
              },
              "examples": {
                "request": {
                  "summary": "Create a webhook",
                  "value": {
                    "url": "https://example.com/dialnexa/webhook",
                    "events": [
                      "call.completed"
                    ],
                    "is_active": true,
                    "secret": "replace-with-a-long-random-secret"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Webhook created successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "error",
                    "statusCode",
                    "message",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "statusCode": {
                      "type": "integer",
                      "example": 201
                    },
                    "message": {
                      "type": "string",
                      "example": "Success"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "message": {
                          "type": "string",
                          "example": "Webhook created successfully"
                        },
                        "webhook": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "example": "webhook_c9v3nz8rq4pmxa",
                              "description": "Webhook ID with the `webhook_` prefix."
                            },
                            "org_id": {
                              "type": "string",
                              "example": "o14XKPP84rt22g",
                              "description": "Owning workspace ID, without the `org_` prefix."
                            },
                            "url": {
                              "type": "string",
                              "format": "uri",
                              "example": "https://example.com/dialnexa/webhook"
                            },
                            "events": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              },
                              "example": [
                                "call.completed"
                              ],
                              "description": "Stored and returned as sent. It does not filter deliveries today."
                            },
                            "is_active": {
                              "type": "boolean",
                              "example": true,
                              "description": "Inactive subscriptions receive no deliveries."
                            },
                            "secret": {
                              "type": "string",
                              "example": "replace-with-a-long-random-secret",
                              "description": "The plain secret you sent. Shown only in this response."
                            },
                            "last_triggered_at": {
                              "type": "string",
                              "format": "date-time",
                              "nullable": true,
                              "description": "When a delivery was last attempted, whether or not your endpoint accepted it."
                            },
                            "is_deleted": {
                              "type": "boolean",
                              "example": false
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            }
                          }
                        }
                      }
                    },
                    "timestamp": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                },
                "examples": {
                  "success": {
                    "summary": "Successful response",
                    "value": {
                      "success": true,
                      "error": false,
                      "statusCode": 201,
                      "message": "Success",
                      "data": {
                        "message": "Webhook created successfully",
                        "webhook": {
                          "id": "webhook_c9v3nz8rq4pmxa",
                          "org_id": "o14XKPP84rt22g",
                          "url": "https://example.com/dialnexa/webhook",
                          "events": [
                            "call.completed"
                          ],
                          "is_active": true,
                          "secret": "replace-with-a-long-random-secret",
                          "last_triggered_at": null,
                          "is_deleted": false,
                          "created_at": "2026-07-03T10:30:00.000Z",
                          "updated_at": "2026-07-03T10:30:00.000Z"
                        }
                      },
                      "timestamp": "2026-09-07T06:00:00.000Z"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request - missing required fields or invalid URL.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "400 Bad Request",
                    "value": {
                      "statusCode": 400,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "url must be a URL address",
                      "errors": [
                        "url must be a URL address"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "401 Unauthorized",
                    "value": {
                      "statusCode": 401,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Invalid API key",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "500 Internal Server Error",
                    "value": {
                      "statusCode": 500,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Internal server error",
                      "errors": []
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "summary": "Create Webhook",
        "tags": [
          "Webhooks"
        ]
      },
      "get": {
        "description": "Returns the workspace's webhook subscriptions, newest first, with page, limit, total and totalPages. Secrets are always masked as ********.",
        "operationId": "listWebhooks",
        "parameters": [
          {
            "name": "limit",
            "required": false,
            "in": "query",
            "description": "Results per page, a whole number of 1 or more (default: 10). Not validated: 0 or a negative value gives an unusable response or an error.",
            "schema": {
              "example": 10,
              "type": "number"
            }
          },
          {
            "name": "page",
            "required": false,
            "in": "query",
            "description": "Page number, a whole number of 1 or more (default: 1).",
            "schema": {
              "example": 1,
              "type": "number"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Webhooks returned successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "error",
                    "statusCode",
                    "message",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "statusCode": {
                      "type": "integer",
                      "example": 200
                    },
                    "message": {
                      "type": "string",
                      "example": "Success"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "message": {
                          "type": "string",
                          "example": "Webhooks fetched successfully"
                        },
                        "webhooks": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string",
                                "example": "webhook_c9v3nz8rq4pmxa",
                                "description": "Webhook ID with the `webhook_` prefix."
                              },
                              "org_id": {
                                "type": "string",
                                "example": "o14XKPP84rt22g",
                                "description": "Owning workspace ID, without the `org_` prefix."
                              },
                              "url": {
                                "type": "string",
                                "format": "uri",
                                "example": "https://example.com/dialnexa/webhook"
                              },
                              "events": {
                                "type": "array",
                                "items": {
                                  "type": "string"
                                },
                                "example": [
                                  "call.completed"
                                ],
                                "description": "Stored and returned as sent. It does not filter deliveries today."
                              },
                              "is_active": {
                                "type": "boolean",
                                "example": true,
                                "description": "Inactive subscriptions receive no deliveries."
                              },
                              "secret": {
                                "type": "string",
                                "example": "********",
                                "description": "Always `********`; only Create Webhook returns the secret."
                              },
                              "last_triggered_at": {
                                "type": "string",
                                "format": "date-time",
                                "nullable": true,
                                "description": "When a delivery was last attempted, whether or not your endpoint accepted it."
                              },
                              "is_deleted": {
                                "type": "boolean",
                                "example": false
                              },
                              "created_at": {
                                "type": "string",
                                "format": "date-time"
                              },
                              "updated_at": {
                                "type": "string",
                                "format": "date-time"
                              }
                            }
                          }
                        },
                        "page": {
                          "type": "number",
                          "example": 1
                        },
                        "limit": {
                          "type": "number",
                          "example": 10
                        },
                        "total": {
                          "type": "number",
                          "example": 1
                        },
                        "totalPages": {
                          "type": "number",
                          "example": 1
                        }
                      }
                    },
                    "timestamp": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                },
                "examples": {
                  "success": {
                    "summary": "Successful response",
                    "value": {
                      "success": true,
                      "error": false,
                      "statusCode": 200,
                      "message": "Success",
                      "data": {
                        "message": "Webhooks fetched successfully",
                        "webhooks": [
                          {
                            "id": "webhook_c9v3nz8rq4pmxa",
                            "org_id": "o14XKPP84rt22g",
                            "url": "https://example.com/dialnexa/webhook",
                            "events": [
                              "call.completed"
                            ],
                            "is_active": true,
                            "secret": "********",
                            "last_triggered_at": null,
                            "is_deleted": false,
                            "created_at": "2026-07-03T10:30:00.000Z",
                            "updated_at": "2026-07-03T10:30:00.000Z"
                          }
                        ],
                        "page": 1,
                        "limit": 10,
                        "total": 1,
                        "totalPages": 1
                      },
                      "timestamp": "2026-09-07T06:00:00.000Z"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "401 Unauthorized",
                    "value": {
                      "statusCode": 401,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Invalid API key",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "500 Internal Server Error",
                    "value": {
                      "statusCode": 500,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Internal server error",
                      "errors": []
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "summary": "List Webhooks",
        "tags": [
          "Webhooks"
        ]
      }
    },
    "/v1/user-webhooks/{id}": {
      "patch": {
        "description": "Updates the URL, events, active flag, or signing secret. Only the fields you send change. The response masks the secret as ********. A new secret signs the next delivery; there is no overlap window.",
        "operationId": "updateWebhook",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "description": "Webhook ID with the `webhook_` prefix, as returned by Create Webhook.",
            "schema": {
              "example": "webhook_c9v3nz8rq4pmxa",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateWebhookRequest"
              },
              "examples": {
                "request": {
                  "summary": "Update a webhook",
                  "value": {
                    "is_active": false
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Webhook updated successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "error",
                    "statusCode",
                    "message",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "statusCode": {
                      "type": "integer",
                      "example": 200
                    },
                    "message": {
                      "type": "string",
                      "example": "Success"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "message": {
                          "type": "string",
                          "example": "Webhook updated successfully"
                        },
                        "webhook": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "example": "webhook_c9v3nz8rq4pmxa",
                              "description": "Webhook ID with the `webhook_` prefix."
                            },
                            "org_id": {
                              "type": "string",
                              "example": "o14XKPP84rt22g",
                              "description": "Owning workspace ID, without the `org_` prefix."
                            },
                            "url": {
                              "type": "string",
                              "format": "uri",
                              "example": "https://example.com/dialnexa/webhook"
                            },
                            "events": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              },
                              "example": [
                                "call.completed"
                              ],
                              "description": "Stored and returned as sent. It does not filter deliveries today."
                            },
                            "is_active": {
                              "type": "boolean",
                              "example": true,
                              "description": "Inactive subscriptions receive no deliveries."
                            },
                            "secret": {
                              "type": "string",
                              "example": "********",
                              "description": "Always `********`; only Create Webhook returns the secret."
                            },
                            "last_triggered_at": {
                              "type": "string",
                              "format": "date-time",
                              "nullable": true,
                              "description": "When a delivery was last attempted, whether or not your endpoint accepted it."
                            },
                            "is_deleted": {
                              "type": "boolean",
                              "example": false
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            }
                          }
                        }
                      }
                    },
                    "timestamp": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                },
                "examples": {
                  "success": {
                    "summary": "Successful response",
                    "value": {
                      "success": true,
                      "error": false,
                      "statusCode": 200,
                      "message": "Success",
                      "data": {
                        "message": "Webhook updated successfully",
                        "webhook": {
                          "id": "webhook_c9v3nz8rq4pmxa",
                          "org_id": "o14XKPP84rt22g",
                          "url": "https://example.com/dialnexa/webhook",
                          "events": [
                            "call.completed"
                          ],
                          "is_active": false,
                          "secret": "********",
                          "last_triggered_at": null,
                          "is_deleted": false,
                          "created_at": "2026-07-03T10:30:00.000Z",
                          "updated_at": "2026-07-04T08:00:00.000Z"
                        }
                      },
                      "timestamp": "2026-09-07T06:00:00.000Z"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request - invalid fields.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "400 Bad Request",
                    "value": {
                      "statusCode": 400,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "url must be a URL address",
                      "errors": [
                        "url must be a URL address"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "401 Unauthorized",
                    "value": {
                      "statusCode": 401,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Invalid API key",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Webhook not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "404 Not Found",
                    "value": {
                      "statusCode": 404,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Webhook not found for the given ID and organization",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "500 Internal Server Error",
                    "value": {
                      "statusCode": 500,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Internal server error",
                      "errors": []
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "summary": "Update Webhook",
        "tags": [
          "Webhooks"
        ]
      },
      "delete": {
        "description": "Deletes a webhook so new events stop being delivered.",
        "operationId": "deleteWebhook",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "description": "Webhook ID with the `webhook_` prefix, as returned by Create Webhook.",
            "schema": {
              "example": "webhook_c9v3nz8rq4pmxa",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Webhook deleted successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "error",
                    "statusCode",
                    "message",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "statusCode": {
                      "type": "integer",
                      "example": 200
                    },
                    "message": {
                      "type": "string",
                      "example": "Success"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "message": {
                          "type": "string",
                          "example": "Webhook deleted successfully"
                        },
                        "id": {
                          "type": "string",
                          "example": "webhook_c9v3nz8rq4pmxa"
                        }
                      }
                    },
                    "timestamp": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                },
                "examples": {
                  "success": {
                    "summary": "Successful response",
                    "value": {
                      "success": true,
                      "error": false,
                      "statusCode": 200,
                      "message": "Success",
                      "data": {
                        "message": "Webhook deleted successfully",
                        "id": "webhook_c9v3nz8rq4pmxa"
                      },
                      "timestamp": "2026-09-07T06:00:00.000Z"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "401 Unauthorized",
                    "value": {
                      "statusCode": 401,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Invalid API key",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Webhook not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "404 Not Found",
                    "value": {
                      "statusCode": 404,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Webhook not found for the given ID and organization",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "500 Internal Server Error",
                    "value": {
                      "statusCode": 500,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Internal server error",
                      "errors": []
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "summary": "Delete Webhook",
        "tags": [
          "Webhooks"
        ]
      },
      "get": {
        "operationId": "getWebhook",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "description": "Webhook ID with the `webhook_` prefix, as returned by Create Webhook.",
            "schema": {
              "example": "webhook_c9v3nz8rq4pmxa",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Webhook returned successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "error",
                    "statusCode",
                    "message",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "statusCode": {
                      "type": "integer",
                      "example": 200
                    },
                    "message": {
                      "type": "string",
                      "example": "Success"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "message": {
                          "type": "string",
                          "example": "Webhook fetched successfully"
                        },
                        "webhook": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "example": "webhook_c9v3nz8rq4pmxa",
                              "description": "Webhook ID with the `webhook_` prefix."
                            },
                            "org_id": {
                              "type": "string",
                              "example": "o14XKPP84rt22g",
                              "description": "Owning workspace ID, without the `org_` prefix."
                            },
                            "url": {
                              "type": "string",
                              "format": "uri",
                              "example": "https://example.com/dialnexa/webhook"
                            },
                            "events": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              },
                              "example": [
                                "call.completed"
                              ],
                              "description": "Stored and returned as sent. It does not filter deliveries today."
                            },
                            "is_active": {
                              "type": "boolean",
                              "example": true,
                              "description": "Inactive subscriptions receive no deliveries."
                            },
                            "secret": {
                              "type": "string",
                              "example": "********",
                              "description": "Always `********`; only Create Webhook returns the secret."
                            },
                            "last_triggered_at": {
                              "type": "string",
                              "format": "date-time",
                              "nullable": true,
                              "description": "When a delivery was last attempted, whether or not your endpoint accepted it."
                            },
                            "is_deleted": {
                              "type": "boolean",
                              "example": false
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updated_at": {
                              "type": "string",
                              "format": "date-time"
                            }
                          }
                        }
                      }
                    },
                    "timestamp": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                },
                "examples": {
                  "success": {
                    "summary": "Successful response",
                    "value": {
                      "success": true,
                      "error": false,
                      "statusCode": 200,
                      "message": "Success",
                      "data": {
                        "message": "Webhook fetched successfully",
                        "webhook": {
                          "id": "webhook_c9v3nz8rq4pmxa",
                          "org_id": "o14XKPP84rt22g",
                          "url": "https://example.com/dialnexa/webhook",
                          "events": [
                            "call.completed"
                          ],
                          "is_active": true,
                          "secret": "********",
                          "last_triggered_at": null,
                          "is_deleted": false,
                          "created_at": "2026-07-03T10:30:00.000Z",
                          "updated_at": "2026-07-03T10:30:00.000Z"
                        }
                      },
                      "timestamp": "2026-09-07T06:00:00.000Z"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "401 Unauthorized",
                    "value": {
                      "statusCode": 401,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Invalid API key",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Webhook not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "404 Not Found",
                    "value": {
                      "statusCode": 404,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Webhook not found for the given ID and organization",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "500 Internal Server Error",
                    "value": {
                      "statusCode": 500,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Internal server error",
                      "errors": []
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "summary": "Get Webhook Details",
        "tags": [
          "Webhooks"
        ],
        "description": "Returns one webhook registration; its signing secret is masked after creation."
      }
    },
    "/v1/voices": {
      "get": {
        "description": "Returns voices with optional filtering by provider, accent, gender, or name. Without llm_id it returns text-to-speech voices only; with llm_id it returns only the voices linked to that LLM.",
        "operationId": "listVoices",
        "parameters": [
          {
            "name": "provider",
            "required": false,
            "in": "query",
            "description": "Filter by TTS provider",
            "schema": {
              "enum": [
                "elevenlabs",
                "smallestai",
                "sarvam",
                "cartesia",
                "soniox"
              ],
              "type": "string"
            }
          },
          {
            "name": "accent",
            "required": false,
            "in": "query",
            "description": "Accent of the voice",
            "schema": {
              "enum": [
                "indian",
                "british",
                "american",
                "canadian",
                "african",
                "australian",
                "swedish"
              ],
              "type": "string"
            }
          },
          {
            "name": "gender",
            "required": false,
            "in": "query",
            "description": "Gender of the voice",
            "schema": {
              "enum": [
                "male",
                "female",
                "non-binary"
              ],
              "type": "string"
            }
          },
          {
            "name": "name",
            "required": false,
            "in": "query",
            "description": "Search by voice name",
            "schema": {
              "example": "English",
              "type": "string"
            }
          },
          {
            "name": "page",
            "required": false,
            "in": "query",
            "description": "Page number (starts from 1)",
            "schema": {
              "minimum": 1,
              "default": 1,
              "example": 1,
              "type": "number"
            }
          },
          {
            "name": "limit",
            "required": false,
            "in": "query",
            "description": "Results per page. Default 20, maximum 50; a larger value returns 400.",
            "schema": {
              "minimum": 1,
              "maximum": 50,
              "default": 20,
              "example": 20,
              "type": "number"
            }
          },
          {
            "name": "language_id",
            "required": false,
            "in": "query",
            "description": "Filter voices that support a specific language ID",
            "schema": {
              "example": "lang_mfgsys4hhg8gdn",
              "type": "string"
            }
          },
          {
            "name": "llm_id",
            "required": false,
            "in": "query",
            "description": "Filter voices compatible with a specific LLM ID (S2S models only)",
            "schema": {
              "example": "llm_mfgt5q2x8k4w7r",
              "type": "string"
            }
          },
          {
            "name": "language_ids",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Comma-separated language IDs. The voice must support every selected language."
          }
        ],
        "responses": {
          "200": {
            "description": "Voices returned successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "name": {
                        "type": "string"
                      },
                      "gender": {
                        "type": "string"
                      },
                      "provider": {
                        "type": "string"
                      },
                      "accent": {
                        "type": "string",
                        "nullable": true
                      }
                    }
                  }
                },
                "examples": {
                  "success": {
                    "summary": "Successful response",
                    "value": [
                      {
                        "id": "voice_mfgt2k9x4q7w1z",
                        "name": "Aditi",
                        "gender": "female",
                        "provider": "elevenlabs",
                        "accent": "indian"
                      }
                    ]
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FilteredErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "401 Unauthorized",
                    "value": {
                      "message": "API key is missing or invalid. You can generate this by logging in into dashboard"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FilteredErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "500 Internal Server Error",
                    "value": {
                      "message": "An unexpected error occurred. Please try again later."
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "A query value is invalid: page or limit below 1 or not a whole number, limit above 50, or a provider, accent or gender outside its list.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FilteredErrorResponse"
                },
                "examples": {
                  "limit": {
                    "summary": "limit above 50",
                    "value": {
                      "message": "Request validation failed: limit must not be greater than 50"
                    }
                  },
                  "page": {
                    "summary": "page below 1",
                    "value": {
                      "message": "Request validation failed: page must not be less than 1"
                    }
                  },
                  "accent": {
                    "summary": "Unknown accent",
                    "value": {
                      "message": "Request validation failed: accent must be one of the following values: "
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "summary": "List Voices",
        "tags": [
          "Voices"
        ]
      }
    },
    "/v1/voices/accents": {
      "get": {
        "description": "Returns the distinct accent values across all non-deleted voices in the catalog, optionally filtered by provider. The list is not scoped to the workspace, so an accent can return no voices in List Voices.",
        "operationId": "listVoiceAccents",
        "parameters": [
          {
            "name": "provider",
            "required": false,
            "in": "query",
            "schema": {
              "enum": [
                "elevenlabs",
                "smallestai",
                "sarvam",
                "cartesia",
                "soniox"
              ],
              "type": "string"
            },
            "description": "Voice provider to list accents for. A value outside the list fails with 500."
          }
        ],
        "responses": {
          "200": {
            "description": "Voice accents returned successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "string",
                    "example": "indian"
                  }
                },
                "examples": {
                  "success": {
                    "summary": "Successful response",
                    "value": [
                      "indian",
                      "american",
                      "british"
                    ]
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FilteredErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "401 Unauthorized",
                    "value": {
                      "message": "API key is missing or invalid. You can generate this by logging in into dashboard"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FilteredErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "500 Internal Server Error",
                    "value": {
                      "message": "An unexpected error occurred. Please try again later."
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "summary": "List Voice Accents",
        "tags": [
          "Voices"
        ]
      }
    },
    "/v1/voices/s2s": {
      "get": {
        "description": "Returns voices that support speech-to-speech mode, along with their compatible languages and LLMs.",
        "operationId": "listSpeechToSpeechVoices",
        "parameters": [],
        "responses": {
          "200": {
            "description": "Speech to speech voices returned successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string",
                        "example": "voice_mj18r4tq2w9xkp"
                      },
                      "name": {
                        "type": "string",
                        "example": "Ash"
                      },
                      "provider": {
                        "type": "string",
                        "example": "openai",
                        "nullable": true
                      },
                      "provider_voice_id": {
                        "type": "string",
                        "example": "ash",
                        "nullable": true
                      },
                      "gender": {
                        "type": "string",
                        "example": "male"
                      },
                      "accent": {
                        "type": "string",
                        "example": "american",
                        "nullable": true
                      },
                      "icon": {
                        "type": "string",
                        "nullable": true
                      },
                      "recording": {
                        "type": "string",
                        "nullable": true
                      },
                      "languages": {
                        "type": "array",
                        "items": {
                          "$ref": "#/components/schemas/SpeechToSpeechLanguage"
                        }
                      },
                      "llms": {
                        "type": "array",
                        "items": {
                          "$ref": "#/components/schemas/SpeechToSpeechModel"
                        }
                      }
                    },
                    "required": [
                      "id",
                      "name",
                      "provider",
                      "provider_voice_id",
                      "gender",
                      "accent",
                      "icon",
                      "recording",
                      "languages",
                      "llms"
                    ]
                  }
                },
                "examples": {
                  "success": {
                    "summary": "Successful response",
                    "value": [
                      {
                        "id": "voice_mj18r4tq2w9xkp",
                        "name": "Ash",
                        "provider": "openai",
                        "provider_voice_id": "ash",
                        "gender": "male",
                        "accent": "american",
                        "icon": null,
                        "recording": "https://speechailogs.blob.core.windows.net/openai-voices/openai-ash-tts.mp3",
                        "languages": [
                          {
                            "id": "lang_mfgsys4f62f0vb",
                            "name": "Hindi",
                            "code": "hi"
                          },
                          {
                            "id": "lang_mfgsys4hhg8gdn",
                            "name": "English",
                            "code": "en"
                          }
                        ],
                        "llms": [
                          {
                            "id": "llm_mj17v3n8k2q5wd",
                            "name": "GPT-realtime-2",
                            "provider": "openai",
                            "provider_id": "gpt-realtime-2"
                          }
                        ]
                      }
                    ]
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FilteredErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "401 Unauthorized",
                    "value": {
                      "message": "API key is missing or invalid. You can generate this by logging in into dashboard"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FilteredErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "500 Internal Server Error",
                    "value": {
                      "message": "An unexpected error occurred. Please try again later."
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "summary": "List Speech-to-Speech Voices",
        "tags": [
          "Voices"
        ]
      }
    },
    "/v1/voices/{id}": {
      "get": {
        "operationId": "getVoice",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "description": "Voice ID",
            "schema": {
              "example": "voice_mfgt2k9x4q7w1z",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Voice returned successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "gender": {
                      "type": "string"
                    },
                    "provider": {
                      "type": "string"
                    },
                    "accent": {
                      "type": "string",
                      "nullable": true
                    }
                  }
                },
                "examples": {
                  "success": {
                    "summary": "Successful response",
                    "value": {
                      "id": "voice_mfgt2k9x4q7w1z",
                      "name": "Aditi",
                      "gender": "female",
                      "provider": "elevenlabs",
                      "accent": "indian"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FilteredErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "401 Unauthorized",
                    "value": {
                      "message": "API key is missing or invalid. You can generate this by logging in into dashboard"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Voice not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FilteredErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "404 Not Found",
                    "value": {
                      "message": "Voice not found"
                    }
                  },
                  "notSupported": {
                    "summary": "Voice outside the supported voice models",
                    "value": {
                      "message": "Voice with ID 2g7Xy3tY53gRlp not found or is deleted"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FilteredErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "500 Internal Server Error",
                    "value": {
                      "message": "An unexpected error occurred. Please try again later."
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "summary": "Get Voice Details",
        "tags": [
          "Voices"
        ],
        "description": "Returns one voice catalog record by ID."
      }
    },
    "/v1/voices/{id}/languages": {
      "get": {
        "operationId": "listVoiceLanguages",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "description": "Voice ID",
            "schema": {
              "example": "voice_mfgt2k9x4q7w1z",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Voice languages returned successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string",
                        "example": "lang_mfgsys4hhg8gdn"
                      },
                      "code": {
                        "type": "string",
                        "example": "en"
                      },
                      "name": {
                        "type": "string",
                        "example": "English"
                      }
                    }
                  }
                },
                "examples": {
                  "success": {
                    "summary": "Successful response",
                    "value": [
                      {
                        "id": "lang_mfgsys4hhg8gdn",
                        "code": "en",
                        "name": "English"
                      },
                      {
                        "id": "lang_mfgsys4f62f0vb",
                        "code": "hi",
                        "name": "Hindi"
                      }
                    ]
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FilteredErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "401 Unauthorized",
                    "value": {
                      "message": "API key is missing or invalid. You can generate this by logging in into dashboard"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Voice not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FilteredErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "404 Not Found",
                    "value": {
                      "message": "Voice not found"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FilteredErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "500 Internal Server Error",
                    "value": {
                      "message": "An unexpected error occurred. Please try again later."
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "summary": "List Voice Languages",
        "tags": [
          "Voices"
        ],
        "description": "Returns the languages supported by one voice."
      }
    },
    "/v1/workflows": {
      "get": {
        "operationId": "listWorkflows",
        "parameters": [
          {
            "name": "page",
            "required": false,
            "in": "query",
            "description": "Page number, starting from 1.",
            "schema": {
              "minimum": 1,
              "default": 1,
              "type": "number"
            }
          },
          {
            "name": "limit",
            "required": false,
            "in": "query",
            "description": "Results per page.",
            "schema": {
              "minimum": 1,
              "default": 10,
              "type": "number"
            }
          },
          {
            "name": "sortBy",
            "required": false,
            "in": "query",
            "description": "Field to sort by.",
            "schema": {
              "default": "created_at",
              "type": "string",
              "enum": [
                "created_at",
                "updated_at",
                "createdAt",
                "updatedAt",
                "title",
                "status",
                "id"
              ]
            }
          },
          {
            "name": "sortOrder",
            "required": false,
            "in": "query",
            "description": "Sort direction.",
            "schema": {
              "default": "DESC",
              "type": "string",
              "enum": [
                "ASC",
                "DESC"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Workflows fetched successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "error",
                    "statusCode",
                    "message",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "statusCode": {
                      "type": "integer",
                      "example": 200
                    },
                    "message": {
                      "type": "string",
                      "example": "Success"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "statusCode": {
                          "type": "number",
                          "example": 200
                        },
                        "message": {
                          "type": "string",
                          "example": "Workflows fetched successfully"
                        },
                        "data": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string",
                                "example": "workflow_abc123"
                              },
                              "title": {
                                "type": "string",
                                "maxLength": 100,
                                "example": "Q3 Outreach Workflow"
                              },
                              "status": {
                                "type": "string",
                                "enum": [
                                  "draft",
                                  "active",
                                  "paused",
                                  "completed",
                                  "cancelled"
                                ],
                                "example": "active"
                              },
                              "description": {
                                "type": "string",
                                "nullable": true,
                                "example": "Automated follow-up sequence"
                              },
                              "organization_id": {
                                "type": "string",
                                "description": "Owning organization (raw ID).",
                                "example": "o14XKPP84rt22g"
                              },
                              "is_deleted": {
                                "type": "boolean",
                                "example": false
                              },
                              "fallback_variables": {
                                "type": "array",
                                "nullable": true,
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "key": {
                                      "type": "string"
                                    },
                                    "default_value": {
                                      "type": "string"
                                    }
                                  }
                                },
                                "description": "Fallback values for lead variables missing from an uploaded lead."
                              },
                              "createdAt": {
                                "type": "string",
                                "format": "date-time"
                              },
                              "updatedAt": {
                                "type": "string",
                                "format": "date-time"
                              },
                              "lead_count": {
                                "type": "integer",
                                "minimum": 0,
                                "description": "Number of non-deleted leads attached to this workflow. A count lookup that cannot complete uses zero."
                              }
                            }
                          }
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "totalItems": {
                              "type": "number",
                              "example": 50
                            },
                            "itemsPerPage": {
                              "type": "number",
                              "example": 10
                            },
                            "totalPages": {
                              "type": "number",
                              "example": 3
                            },
                            "currentPage": {
                              "type": "number",
                              "example": 1
                            }
                          }
                        }
                      }
                    },
                    "timestamp": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                },
                "examples": {
                  "success": {
                    "summary": "Successful response",
                    "value": {
                      "success": true,
                      "error": false,
                      "statusCode": 200,
                      "message": "Success",
                      "data": {
                        "statusCode": 200,
                        "message": "Workflows fetched successfully",
                        "data": [
                          {
                            "id": "workflow_abc123",
                            "title": "Q3 Outreach Workflow",
                            "status": "active",
                            "description": "Automated follow-up sequence",
                            "organization_id": "o14XKPP84rt22g",
                            "is_deleted": false,
                            "fallback_variables": [],
                            "createdAt": "2026-07-03T10:30:00.000Z",
                            "updatedAt": "2026-07-03T10:45:00.000Z",
                            "lead_count": 1
                          }
                        ],
                        "meta": {
                          "totalItems": 1,
                          "itemsPerPage": 10,
                          "totalPages": 1,
                          "currentPage": 1
                        }
                      },
                      "timestamp": "2026-09-07T06:00:00.000Z"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid query parameters.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "400 Bad Request",
                    "value": {
                      "statusCode": 400,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "sortBy must be one of the following values: created_at, updated_at, createdAt, updatedAt, title, status, id",
                      "errors": [
                        "sortBy must be one of the following values: created_at, updated_at, createdAt, updatedAt, title, status, id"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "401 Unauthorized",
                    "value": {
                      "statusCode": 401,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Invalid API key",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "500 Internal Server Error",
                    "value": {
                      "statusCode": 500,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Error fetching workflows: Internal server error",
                      "errors": []
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "summary": "List Workflows",
        "tags": [
          "Workflows"
        ],
        "description": "Returns workflows for the authenticated workspace in a data and meta pagination envelope."
      }
    },
    "/v1/workflows/{id}": {
      "get": {
        "operationId": "getWorkflow",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "description": "Workflow ID",
            "schema": {
              "example": "workflow_abc123",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Workflow fetched successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "error",
                    "statusCode",
                    "message",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "statusCode": {
                      "type": "integer",
                      "example": 200
                    },
                    "message": {
                      "type": "string",
                      "example": "Success"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "statusCode": {
                          "type": "number",
                          "example": 200
                        },
                        "message": {
                          "type": "string",
                          "example": "Workflow fetched successfully"
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "example": "workflow_abc123"
                            },
                            "title": {
                              "type": "string",
                              "maxLength": 100,
                              "example": "Q3 Outreach Workflow"
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "draft",
                                "active",
                                "paused",
                                "completed",
                                "cancelled"
                              ],
                              "example": "active"
                            },
                            "description": {
                              "type": "string",
                              "nullable": true,
                              "example": "Automated follow-up sequence"
                            },
                            "organization_id": {
                              "type": "string",
                              "description": "Owning organization (raw ID).",
                              "example": "o14XKPP84rt22g"
                            },
                            "is_deleted": {
                              "type": "boolean",
                              "example": false
                            },
                            "fallback_variables": {
                              "type": "array",
                              "nullable": true,
                              "items": {
                                "type": "object",
                                "properties": {
                                  "key": {
                                    "type": "string"
                                  },
                                  "default_value": {
                                    "type": "string"
                                  }
                                }
                              },
                              "description": "Fallback values for lead variables missing from an uploaded lead."
                            },
                            "createdAt": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updatedAt": {
                              "type": "string",
                              "format": "date-time"
                            }
                          }
                        }
                      }
                    },
                    "timestamp": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                },
                "examples": {
                  "success": {
                    "summary": "Successful response",
                    "value": {
                      "success": true,
                      "error": false,
                      "statusCode": 200,
                      "message": "Success",
                      "data": {
                        "statusCode": 200,
                        "message": "Workflow fetched successfully",
                        "data": {
                          "id": "workflow_abc123",
                          "title": "Q3 Outreach Workflow",
                          "status": "active",
                          "description": "Automated follow-up sequence",
                          "organization_id": "o14XKPP84rt22g",
                          "is_deleted": false,
                          "fallback_variables": [],
                          "createdAt": "2026-07-03T10:30:00.000Z",
                          "updatedAt": "2026-07-03T10:45:00.000Z"
                        }
                      },
                      "timestamp": "2026-09-07T06:00:00.000Z"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "401 Unauthorized",
                    "value": {
                      "statusCode": 401,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Invalid API key",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Workflow not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "404 Not Found",
                    "value": {
                      "statusCode": 404,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Workflow with ID Hk3pW9zQe1LmRt not found",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "500 Internal Server Error",
                    "value": {
                      "statusCode": 500,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Internal server error",
                      "errors": []
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "summary": "Get Workflow Details",
        "tags": [
          "Workflows"
        ],
        "description": "Returns one workflow and its current lifecycle state."
      }
    },
    "/v1/workflows/{id}/status": {
      "patch": {
        "operationId": "updateWorkflowStatus",
        "summary": "Update Workflow Status",
        "description": "Changes a workflow status. `activate` (from `draft` or `paused`) runs the pre-activation checks, sets the workflow `active` and starts every lead that has no execution yet. `deactivate` and `pause` (from `active`) set it `paused`: no new lead starts, including through an inbound call, and queued calls are not dialed. Leads already inside a step keep advancing: an expiring time hold or a finished call can still move a lead into a Voice Call node, whose call is queued and dialed once the workflow is active again, and an inbound call from such a lead is still routed into the workflow. `resume` (from `paused`) sets it `active` again without starting leads that were uploaded while it was paused; use `activate` for those.",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "description": "Workflow ID",
            "schema": {
              "example": "workflow_abc123",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateWorkflowStatusRequest"
              },
              "examples": {
                "activate": {
                  "summary": "Activate a workflow",
                  "value": {
                    "action": "activate"
                  }
                },
                "deactivate": {
                  "summary": "Deactivate a workflow",
                  "value": {
                    "action": "deactivate"
                  }
                },
                "pause": {
                  "summary": "Pause a workflow",
                  "value": {
                    "action": "pause"
                  }
                },
                "resume": {
                  "summary": "Resume a workflow",
                  "value": {
                    "action": "resume"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Workflow status updated successfully.",
            "content": {
              "application/json": {
                "examples": {
                  "success": {
                    "summary": "Successful response",
                    "value": {
                      "success": true,
                      "error": false,
                      "statusCode": 200,
                      "message": "Success",
                      "data": {
                        "statusCode": 200,
                        "message": "Workflow activated successfully",
                        "data": {
                          "id": "workflow_abc123",
                          "title": "Q3 Outreach Workflow",
                          "status": "active",
                          "description": "Automated follow-up sequence",
                          "organization_id": "o14XKPP84rt22g",
                          "is_deleted": false,
                          "fallback_variables": [],
                          "createdAt": "2026-07-03T10:30:00.000Z",
                          "updatedAt": "2026-07-03T10:45:00.000Z"
                        }
                      },
                      "timestamp": "2026-09-07T06:00:00.000Z"
                    }
                  }
                },
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "error",
                    "statusCode",
                    "message",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "statusCode": {
                      "type": "integer",
                      "example": 200
                    },
                    "message": {
                      "type": "string",
                      "example": "Success"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "statusCode": {
                          "type": "number",
                          "example": 200
                        },
                        "message": {
                          "type": "string",
                          "example": "Workflow activated successfully",
                          "description": "Workflow activated, deactivated, paused or resumed successfully."
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "example": "workflow_abc123"
                            },
                            "title": {
                              "type": "string",
                              "maxLength": 100,
                              "example": "Q3 Outreach Workflow"
                            },
                            "status": {
                              "type": "string",
                              "enum": [
                                "draft",
                                "active",
                                "paused",
                                "completed",
                                "cancelled"
                              ],
                              "example": "active"
                            },
                            "description": {
                              "type": "string",
                              "nullable": true,
                              "example": "Automated follow-up sequence"
                            },
                            "organization_id": {
                              "type": "string",
                              "description": "Owning organization (raw ID).",
                              "example": "o14XKPP84rt22g"
                            },
                            "is_deleted": {
                              "type": "boolean",
                              "example": false
                            },
                            "fallback_variables": {
                              "type": "array",
                              "nullable": true,
                              "items": {
                                "type": "object",
                                "properties": {
                                  "key": {
                                    "type": "string"
                                  },
                                  "default_value": {
                                    "type": "string"
                                  }
                                }
                              },
                              "description": "Fallback values for lead variables missing from an uploaded lead."
                            },
                            "createdAt": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "updatedAt": {
                              "type": "string",
                              "format": "date-time"
                            }
                          }
                        }
                      }
                    },
                    "timestamp": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid action, or the action is not allowed for the workflow's current status (for example pausing a workflow that is not active, resuming one that is not paused, or activating one that is already active, completed or cancelled).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "400 Bad Request",
                    "value": {
                      "statusCode": 400,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "action must be one of the following values: activate, deactivate, pause, resume",
                      "errors": [
                        "action must be one of the following values: activate, deactivate, pause, resume"
                      ]
                    }
                  },
                  "alreadyActive": {
                    "summary": "Activate an active workflow",
                    "value": {
                      "statusCode": 400,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Workflow is already active",
                      "errors": [
                        "Workflow is already active"
                      ]
                    }
                  },
                  "cannotActivate": {
                    "summary": "Activate a completed workflow",
                    "value": {
                      "statusCode": 400,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Cannot activate workflow with status: completed",
                      "errors": [
                        "Cannot activate workflow with status: completed"
                      ]
                    }
                  },
                  "cannotPause": {
                    "summary": "Pause a workflow that is not active",
                    "value": {
                      "statusCode": 400,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Cannot pause workflow with status: draft",
                      "errors": [
                        "Cannot pause workflow with status: draft"
                      ]
                    }
                  },
                  "cannotResume": {
                    "summary": "Resume a workflow that is not paused",
                    "value": {
                      "statusCode": 400,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Cannot resume workflow with status: active",
                      "errors": [
                        "Cannot resume workflow with status: active"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "401 Unauthorized",
                    "value": {
                      "statusCode": 401,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Invalid API key",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Workflow not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "404 Not Found",
                    "value": {
                      "statusCode": 404,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Workflow with ID Hk3pW9zQe1LmRt not found",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "500 Internal Server Error",
                    "value": {
                      "statusCode": 500,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Internal server error",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable: `activate` ran the pre-activation checks and the workflow failed them. data.errors lists what to fix; data.warnings lists non-blocking issues.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "activationChecksFailed": {
                    "summary": "422 Unprocessable Entity",
                    "value": {
                      "statusCode": 422,
                      "error": true,
                      "success": false,
                      "data": {
                        "errors": [
                          {
                            "type": "PHONE_NUMBER_MISSING",
                            "node_id": "Rt5vN8kQ2wLz7x",
                            "node_label": "Call lead",
                            "detail": "VoiceCall node \"Call lead\" has no phone number configured"
                          }
                        ],
                        "warnings": []
                      },
                      "message": "Workflow cannot be activated due to validation errors. Please fix the issues listed and try again.",
                      "errors": []
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "tags": [
          "Workflows"
        ]
      }
    },
    "/v1/workflows/{workflowId}/leads": {
      "post": {
        "operationId": "uploadWorkflowLeads",
        "parameters": [
          {
            "name": "workflowId",
            "required": true,
            "in": "path",
            "description": "Workflow ID",
            "schema": {
              "example": "workflow_abc123",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "file": {
                    "type": "string",
                    "format": "binary",
                    "description": "CSV, XLSX, or XLS file, at most 10 MB (10485760 bytes). The part's Content-Type must be text/csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet or application/vnd.ms-excel, and the file name must end in .csv, .xlsx or .xls."
                  },
                  "tags": {
                    "type": "string",
                    "description": "Optional comma- or pipe-separated labels for every lead. Unioned with the reserved tags column, normalized to lowercase, at most 20 tags per lead and 40 characters per tag."
                  }
                },
                "required": [
                  "file"
                ]
              },
              "examples": {
                "request": {
                  "summary": "Upload workflow leads file",
                  "value": {
                    "file": "workflow-leads.csv"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "File processed successfully.",
            "content": {
              "application/json": {
                "examples": {
                  "success": {
                    "summary": "All rows created",
                    "value": {
                      "success": true,
                      "error": false,
                      "statusCode": 201,
                      "message": "Success",
                      "data": {
                        "statusCode": 201,
                        "message": "Leads uploaded successfully",
                        "data": {
                          "+919876543210": [
                            "lead_abc123"
                          ],
                          "+919123456789": [
                            "lead_def456"
                          ]
                        },
                        "count": 2,
                        "tags": [
                          "priority"
                        ],
                        "dnc_skipped_count": 0
                      },
                      "timestamp": "2026-09-07T06:00:00.000Z"
                    }
                  },
                  "partial": {
                    "summary": "Some rows failed",
                    "value": {
                      "success": true,
                      "error": false,
                      "statusCode": 201,
                      "message": "Success",
                      "data": {
                        "statusCode": 201,
                        "message": "Leads uploaded with 2 row(s) failed.",
                        "data": {
                          "+919876543210": [
                            "lead_abc123"
                          ],
                          "+919123456789": [
                            "lead_def456"
                          ]
                        },
                        "count": 2,
                        "tags": [],
                        "errors": [
                          "Row 1 (phone: +919876543210): Phone number phn_abc123 not found or not active for VoiceCall node Rt5vN8kQ2wLz7x",
                          "Row 2 (phone: +919123456789): Phone number phn_abc123 not found or not active for VoiceCall node Rt5vN8kQ2wLz7x"
                        ],
                        "unused_columns": [
                          "product"
                        ],
                        "allowed_columns": [
                          "customer_name"
                        ],
                        "dnc_skipped_count": 0
                      },
                      "timestamp": "2026-09-07T06:00:00.000Z"
                    }
                  }
                },
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "error",
                    "statusCode",
                    "message",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "statusCode": {
                      "type": "integer",
                      "example": 201
                    },
                    "message": {
                      "type": "string",
                      "example": "Success"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "statusCode": {
                          "type": "number",
                          "example": 201
                        },
                        "message": {
                          "type": "string",
                          "example": "Leads uploaded successfully",
                          "description": "`Leads uploaded successfully`, or `Leads uploaded with N row(s) failed.` when `errors` is present."
                        },
                        "data": {
                          "type": "object",
                          "description": "Created lead IDs grouped by the phone number exactly as it appears in the file.",
                          "additionalProperties": {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "example": "lead_abc123"
                            }
                          }
                        },
                        "count": {
                          "type": "number",
                          "example": 1,
                          "description": "Number of leads created."
                        },
                        "tags": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          },
                          "description": "Every tag applied in this upload."
                        },
                        "errors": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          },
                          "description": "Present only when some rows failed, one message per row: the lead could not be saved, or, on an active workflow, it was saved (and is in data and count) but its execution could not start."
                        },
                        "unused_columns": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          },
                          "description": "Present only when some data columns are not referenced by any node or agent prompt in the workflow. The reserved notes and agent_transfer_destinations columns can also be listed."
                        },
                        "allowed_columns": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          },
                          "description": "Present with unused_columns: the variable names the workflow does reference."
                        },
                        "dnc_skipped_count": {
                          "type": "integer",
                          "example": 0,
                          "description": "Rows left out because their number is on the workspace's DNC list. 0 when none was."
                        }
                      }
                    },
                    "timestamp": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Missing file, wrong extension or MIME type, malformed CSV, no row with a phone number, invalid notes, transfer destinations or tags, or rows whose phone number fails destination validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "400 Bad Request",
                    "value": {
                      "statusCode": 400,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "File must be a CSV or Excel file (.csv, .xlsx, .xls)",
                      "errors": []
                    }
                  },
                  "rowValidation": {
                    "summary": "Rows whose numbers fail validation",
                    "value": {
                      "statusCode": 400,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "1 phone number failed validation.\nPhone Number \"12345\" Could Not Be Parsed. Use International Format Such As +447700900123. (row: 3)",
                      "errors": [
                        "Phone Number \"12345\" Could Not Be Parsed. Use International Format Such As +447700900123. (row: 3)"
                      ],
                      "validation_errors": [
                        {
                          "error": "Phone Number \"12345\" Could Not Be Parsed. Use International Format Such As +447700900123.",
                          "rows": [
                            3
                          ],
                          "phone_numbers": [
                            "12345"
                          ]
                        }
                      ],
                      "invalid_row_count": 1
                    }
                  },
                  "allNumbersOnDnc": {
                    "summary": "Every number is on the DNC list",
                    "value": {
                      "statusCode": 400,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "All 2 numbers in this file are on your workspace's DNC list, so there is nothing to call.",
                      "errors": [
                        "All 2 numbers in this file are on your workspace's DNC list, so there is nothing to call."
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "401 Unauthorized",
                    "value": {
                      "statusCode": 401,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Invalid API key",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Workflow not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "404 Not Found",
                    "value": {
                      "statusCode": 404,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Workflow with ID Hk3pW9zQe1LmRt not found",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "The uploaded file is larger than 10 MB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "413 Payload Too Large",
                    "value": {
                      "statusCode": 413,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "File too large",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "500 Internal Server Error",
                    "value": {
                      "statusCode": 500,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Something went wrong while processing your request.",
                      "errors": []
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "summary": "Upload Workflow Leads",
        "tags": [
          "Workflow Leads"
        ],
        "description": "Uploads and enrolls leads in one workflow from a CSV or Excel file. On a `draft` workflow the upload replaces every existing lead; on an `active` or `paused` workflow it adds to them. Leads uploaded to an `active` workflow start immediately; leads uploaded to a `paused` workflow start only when the workflow is activated again with `activate`. A 201 can be a partial success: rows listed in `errors` either could not be saved or, on an `active` workflow, were saved but could not start; a saved row is still counted in `data` and `count`."
      },
      "get": {
        "operationId": "listWorkflowLeads",
        "parameters": [
          {
            "name": "workflowId",
            "required": true,
            "in": "path",
            "description": "Workflow ID",
            "schema": {
              "example": "workflow_abc123",
              "type": "string"
            }
          },
          {
            "name": "leadIds",
            "required": false,
            "in": "query",
            "description": "Comma-separated lead IDs to filter",
            "schema": {
              "example": "lead_abc123,lead_def456",
              "type": "string"
            }
          },
          {
            "name": "page",
            "required": false,
            "in": "query",
            "description": "1-based page number. Omit page and limit to return every lead, as before.",
            "schema": {
              "example": 1,
              "type": "number"
            }
          },
          {
            "name": "limit",
            "required": false,
            "in": "query",
            "description": "Leads per page (default 50, max 200). Only applies when paging is requested.",
            "schema": {
              "example": 50,
              "type": "number"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Leads returned successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "error",
                    "statusCode",
                    "message",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "statusCode": {
                      "type": "integer",
                      "example": 200
                    },
                    "message": {
                      "type": "string",
                      "example": "Success"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "statusCode": {
                          "type": "number",
                          "example": 200
                        },
                        "message": {
                          "type": "string",
                          "example": "Leads fetched successfully"
                        },
                        "data": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string",
                                "example": "lead_abc123"
                              },
                              "workflow_id": {
                                "type": "string",
                                "description": "Raw workflow ID, without the workflow_ prefix.",
                                "example": "Hk3pW9zQe1LmRt"
                              },
                              "organization_id": {
                                "type": "string",
                                "example": "o14XKPP84rt22g"
                              },
                              "phone_number": {
                                "type": "string",
                                "description": "As it appeared in the uploaded file.",
                                "example": "+919876543210"
                              },
                              "dynamic_variables": {
                                "type": "array",
                                "description": "One entry per non-empty data cell of the uploaded file. Blank cells add no entry; values are trimmed and inner whitespace is collapsed.",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "key": {
                                      "type": "string",
                                      "example": "customer_name"
                                    },
                                    "value": {
                                      "type": "string",
                                      "example": "Priya Sharma"
                                    },
                                    "fallback": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "key",
                                    "value"
                                  ]
                                }
                              },
                              "notes": {
                                "type": "object",
                                "nullable": true,
                                "description": "The reserved notes column: a JSON object of at most 15 keys, or plain text stored as {\"text\": \"<cell>\"}."
                              },
                              "tags": {
                                "type": "array",
                                "nullable": true,
                                "items": {
                                  "type": "string",
                                  "maxLength": 40
                                },
                                "maxItems": 20,
                                "description": "Null on leads uploaded before tags existed."
                              },
                              "is_deleted": {
                                "type": "boolean",
                                "example": false
                              },
                              "status": {
                                "type": "string",
                                "enum": [
                                  "pending",
                                  "active",
                                  "completed",
                                  "dropped",
                                  "failed",
                                  "dnc_blocked"
                                ],
                                "example": "active"
                              },
                              "current_node_id": {
                                "type": "string",
                                "nullable": true
                              },
                              "entry_time": {
                                "type": "string",
                                "format": "date-time",
                                "nullable": true
                              },
                              "completed_at": {
                                "type": "string",
                                "format": "date-time",
                                "nullable": true
                              },
                              "createdAt": {
                                "type": "string",
                                "format": "date-time"
                              },
                              "updatedAt": {
                                "type": "string",
                                "format": "date-time"
                              },
                              "created_at": {
                                "type": "string",
                                "format": "date-time"
                              },
                              "updated_at": {
                                "type": "string",
                                "format": "date-time"
                              }
                            }
                          }
                        },
                        "count": {
                          "type": "number",
                          "example": 42
                        },
                        "total": {
                          "type": "integer",
                          "minimum": 0,
                          "description": "All leads matching the filter, across pages. count remains the number returned on this page."
                        }
                      }
                    },
                    "timestamp": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                },
                "examples": {
                  "success": {
                    "summary": "Successful response",
                    "value": {
                      "success": true,
                      "error": false,
                      "statusCode": 200,
                      "message": "Success",
                      "data": {
                        "statusCode": 200,
                        "message": "Leads fetched successfully",
                        "data": [
                          {
                            "id": "lead_abc123",
                            "workflow_id": "Hk3pW9zQe1LmRt",
                            "organization_id": "o14XKPP84rt22g",
                            "phone_number": "+919876543210",
                            "dynamic_variables": [
                              {
                                "key": "customer_name",
                                "value": "Priya Sharma"
                              },
                              {
                                "key": "loan_amount",
                                "value": "500000"
                              }
                            ],
                            "notes": null,
                            "tags": [
                              "priority"
                            ],
                            "is_deleted": false,
                            "status": "active",
                            "current_node_id": "Rt5vN8kQ2wLz7x",
                            "entry_time": "2026-07-03T10:31:00.000Z",
                            "completed_at": null,
                            "createdAt": "2026-07-03T10:30:00.000Z",
                            "updatedAt": "2026-07-03T10:30:00.000Z",
                            "created_at": "2026-07-03T10:30:00.000Z",
                            "updated_at": "2026-07-03T10:30:00.000Z"
                          }
                        ],
                        "count": 1,
                        "total": 1
                      },
                      "timestamp": "2026-09-07T06:00:00.000Z"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "401 Unauthorized",
                    "value": {
                      "statusCode": 401,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Invalid API key",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "500 Internal Server Error",
                    "value": {
                      "statusCode": 500,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Error fetching workflow leads: Internal server error",
                      "errors": []
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "summary": "List Workflow Leads",
        "tags": [
          "Workflow Leads"
        ],
        "description": "Returns the leads enrolled in one workflow, newest first, with each lead's latest execution status. An unknown workflow ID returns an empty list."
      }
    },
    "/v1/workflows/{workflowId}/leads/variable-keys": {
      "get": {
        "operationId": "listWorkflowLeadVariableKeys",
        "parameters": [
          {
            "name": "workflowId",
            "required": true,
            "in": "path",
            "description": "Workflow ID",
            "schema": {
              "example": "workflow_abc123",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Variable keys returned successfully.",
            "content": {
              "application/json": {
                "examples": {
                  "success": {
                    "summary": "Successful response",
                    "value": {
                      "success": true,
                      "error": false,
                      "statusCode": 200,
                      "message": "Success",
                      "data": {
                        "statusCode": 200,
                        "message": "Variable keys fetched successfully",
                        "data": {
                          "keys": [
                            "customer_name",
                            "loan_amount",
                            "product"
                          ]
                        }
                      },
                      "timestamp": "2026-09-07T06:00:00.000Z"
                    }
                  }
                },
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "error",
                    "statusCode",
                    "message",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "statusCode": {
                      "type": "integer",
                      "example": 200
                    },
                    "message": {
                      "type": "string",
                      "example": "Success"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "statusCode": {
                          "type": "number",
                          "example": 200
                        },
                        "message": {
                          "type": "string",
                          "example": "Variable keys fetched successfully"
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "keys": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              },
                              "description": "Sorted, de-duplicated keys."
                            }
                          }
                        }
                      }
                    },
                    "timestamp": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "401 Unauthorized",
                    "value": {
                      "statusCode": 401,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Invalid API key",
                      "errors": []
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "summary": "Get Workflow Lead Variables",
        "tags": [
          "Workflow Leads"
        ],
        "description": "Returns the sorted dynamic variable keys carried by the leads currently enrolled in one workflow. An unknown workflow ID returns an empty list."
      }
    },
    "/v1/workflows/{workflowId}/leads/{id}": {
      "delete": {
        "operationId": "deleteWorkflowLead",
        "parameters": [
          {
            "name": "workflowId",
            "required": true,
            "in": "path",
            "description": "Workflow ID",
            "schema": {
              "example": "workflow_abc123",
              "type": "string"
            }
          },
          {
            "name": "id",
            "required": true,
            "in": "path",
            "description": "Lead ID",
            "schema": {
              "example": "lead_abc123",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Lead removed successfully.",
            "content": {
              "application/json": {
                "examples": {
                  "success": {
                    "summary": "Successful response",
                    "value": {
                      "success": true,
                      "error": false,
                      "statusCode": 200,
                      "message": "Success",
                      "data": {
                        "statusCode": 200,
                        "message": "Lead soft-deleted successfully"
                      },
                      "timestamp": "2026-09-07T06:00:00.000Z"
                    }
                  }
                },
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "error",
                    "statusCode",
                    "message",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "statusCode": {
                      "type": "integer",
                      "example": 200
                    },
                    "message": {
                      "type": "string",
                      "example": "Success"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "statusCode": {
                          "type": "number",
                          "example": 200
                        },
                        "message": {
                          "type": "string",
                          "description": "Confirmation text."
                        }
                      }
                    },
                    "timestamp": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "401 Unauthorized",
                    "value": {
                      "statusCode": 401,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Invalid API key",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Lead not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "404 Not Found",
                    "value": {
                      "statusCode": 404,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Workflow lead with ID Bv7nC2xKs5DqYw not found",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "500 Internal Server Error",
                    "value": {
                      "statusCode": 500,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Internal server error",
                      "errors": []
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "summary": "Delete Workflow Lead",
        "tags": [
          "Workflow Leads"
        ],
        "description": "Removes one lead from a workflow. The lead leaves the lead list and no longer matches inbound calls. Steps already scheduled or in progress for the lead are not cancelled and can still place a call."
      }
    },
    "/v1/workflows/{workflowId}/leads/{id}/history": {
      "get": {
        "operationId": "getWorkflowLeadHistory",
        "parameters": [
          {
            "name": "workflowId",
            "required": true,
            "in": "path",
            "description": "Workflow ID",
            "schema": {
              "example": "workflow_abc123",
              "type": "string"
            }
          },
          {
            "name": "id",
            "required": true,
            "in": "path",
            "description": "Lead ID",
            "schema": {
              "example": "lead_abc123",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Lead execution history returned successfully.",
            "content": {
              "application/json": {
                "examples": {
                  "success": {
                    "summary": "Successful response",
                    "value": {
                      "success": true,
                      "error": false,
                      "statusCode": 200,
                      "message": "Success",
                      "data": {
                        "statusCode": 200,
                        "message": "Lead history fetched successfully",
                        "data": {
                          "lead": {
                            "id": "lead_abc123",
                            "phone_number": "+919876543210",
                            "dynamic_variables": [
                              {
                                "key": "customer_name",
                                "value": "Priya Sharma"
                              },
                              {
                                "key": "loan_amount",
                                "value": "500000"
                              }
                            ],
                            "notes": null
                          },
                          "execution": {
                            "id": "Ex8nT4vQ1mLz6c",
                            "current_node_id": "Wq3mK7pL9xNz2b",
                            "status": "completed",
                            "entry_time": "2026-07-03T10:31:00.000Z"
                          },
                          "history": [
                            {
                              "id": "Hs2kP9wQ4nLx7v",
                              "from_node": null,
                              "to_node": {
                                "id": "Rt5vN8kQ2wLz7x",
                                "label": "First call",
                                "node_type": "VOICE_CALL",
                                "config": {
                                  "phone_number_id": "phn_abc123"
                                }
                              },
                              "transition_reason": "Entered workflow at entry node",
                              "metadata": {},
                              "transitioned_at": "2026-07-03T10:31:00.000Z"
                            },
                            {
                              "id": "Hs5mR3tY8bKw1q",
                              "from_node": {
                                "id": "Rt5vN8kQ2wLz7x",
                                "label": "First call",
                                "node_type": "VOICE_CALL",
                                "config": {
                                  "phone_number_id": "phn_abc123"
                                }
                              },
                              "to_node": {
                                "id": "Wq3mK7pL9xNz2b",
                                "label": "Converted",
                                "node_type": "CONVERTED",
                                "config": {}
                              },
                              "transition_reason": "Call COMPLETED: completed",
                              "metadata": {
                                "call_id": "Cl7vB2nM5xQz9k",
                                "call_status": "completed"
                              },
                              "transitioned_at": "2026-07-03T10:36:10.000Z"
                            },
                            {
                              "id": "Hs8tW1nB6vQz3m",
                              "from_node": {
                                "id": "Wq3mK7pL9xNz2b",
                                "label": "Converted",
                                "node_type": "CONVERTED",
                                "config": {}
                              },
                              "to_node": {
                                "id": "Wq3mK7pL9xNz2b",
                                "label": "Converted",
                                "node_type": "CONVERTED",
                                "config": {}
                              },
                              "transition_reason": "Reached CONVERTED terminal node",
                              "metadata": {},
                              "transitioned_at": "2026-07-03T10:36:10.000Z"
                            }
                          ],
                          "all_nodes": [
                            {
                              "id": "Rt5vN8kQ2wLz7x",
                              "label": "First call",
                              "node_type": "VOICE_CALL",
                              "config": {
                                "phone_number_id": "phn_abc123",
                                "phone_number_display": "+919876500000"
                              },
                              "position_x": 100,
                              "position_y": 100
                            },
                            {
                              "id": "Wq3mK7pL9xNz2b",
                              "label": "Converted",
                              "node_type": "CONVERTED",
                              "config": {},
                              "position_x": 400,
                              "position_y": 100
                            }
                          ],
                          "all_edges": [
                            {
                              "id": "Ed4jH6kL2mNp8r",
                              "from_node_id": "Rt5vN8kQ2wLz7x",
                              "to_node_id": "Wq3mK7pL9xNz2b",
                              "label": "COMPLETED"
                            }
                          ]
                        }
                      },
                      "timestamp": "2026-09-07T06:00:00.000Z"
                    }
                  }
                },
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "error",
                    "statusCode",
                    "message",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "statusCode": {
                      "type": "integer",
                      "example": 200
                    },
                    "message": {
                      "type": "string",
                      "example": "Success"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "statusCode": {
                          "type": "number",
                          "example": 200
                        },
                        "message": {
                          "type": "string",
                          "example": "Lead history fetched successfully"
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "lead": {
                              "type": "object",
                              "properties": {
                                "id": {
                                  "type": "string",
                                  "example": "lead_abc123"
                                },
                                "phone_number": {
                                  "type": "string"
                                },
                                "dynamic_variables": {
                                  "type": "array",
                                  "description": "One entry per non-empty data cell of the uploaded file. Blank cells add no entry; values are trimmed and inner whitespace is collapsed.",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "key": {
                                        "type": "string",
                                        "example": "customer_name"
                                      },
                                      "value": {
                                        "type": "string",
                                        "example": "Priya Sharma"
                                      },
                                      "fallback": {
                                        "type": "string"
                                      }
                                    },
                                    "required": [
                                      "key",
                                      "value"
                                    ]
                                  }
                                },
                                "notes": {
                                  "type": "object",
                                  "nullable": true,
                                  "description": "The reserved notes column: a JSON object of at most 15 keys, or plain text stored as {\"text\": \"<cell>\"}."
                                }
                              }
                            },
                            "execution": {
                              "type": "object",
                              "nullable": true,
                              "properties": {
                                "id": {
                                  "type": "string"
                                },
                                "current_node_id": {
                                  "type": "string"
                                },
                                "status": {
                                  "type": "string",
                                  "enum": [
                                    "active",
                                    "completed",
                                    "dropped",
                                    "failed",
                                    "dnc_blocked"
                                  ]
                                },
                                "entry_time": {
                                  "type": "string",
                                  "format": "date-time"
                                }
                              }
                            },
                            "history": {
                              "type": "array",
                              "description": "Transitions, oldest first. IDs are raw, without prefixes.",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string"
                                  },
                                  "from_node": {
                                    "type": "object",
                                    "nullable": true,
                                    "properties": {
                                      "id": {
                                        "type": "string"
                                      },
                                      "label": {
                                        "type": "string"
                                      },
                                      "node_type": {
                                        "type": "string",
                                        "enum": [
                                          "VOICE_CALL",
                                          "CONDITIONAL",
                                          "TIME",
                                          "APPLICATION",
                                          "CUSTOM_FUNCTION",
                                          "CONVERTED",
                                          "DROPPED"
                                        ]
                                      },
                                      "config": {
                                        "type": "object"
                                      }
                                    }
                                  },
                                  "to_node": {
                                    "type": "object",
                                    "nullable": true,
                                    "properties": {
                                      "id": {
                                        "type": "string"
                                      },
                                      "label": {
                                        "type": "string"
                                      },
                                      "node_type": {
                                        "type": "string",
                                        "enum": [
                                          "VOICE_CALL",
                                          "CONDITIONAL",
                                          "TIME",
                                          "APPLICATION",
                                          "CUSTOM_FUNCTION",
                                          "CONVERTED",
                                          "DROPPED"
                                        ]
                                      },
                                      "config": {
                                        "type": "object"
                                      }
                                    }
                                  },
                                  "transition_reason": {
                                    "type": "string"
                                  },
                                  "metadata": {
                                    "type": "object",
                                    "description": "After a Voice Call node: call_id (raw call ID) and call_status."
                                  },
                                  "transitioned_at": {
                                    "type": "string",
                                    "format": "date-time"
                                  }
                                }
                              }
                            },
                            "all_nodes": {
                              "type": "array",
                              "description": "Every node in the workflow. Voice Call node config also carries phone_number_display.",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string"
                                  },
                                  "label": {
                                    "type": "string"
                                  },
                                  "node_type": {
                                    "type": "string"
                                  },
                                  "config": {
                                    "type": "object"
                                  },
                                  "position_x": {
                                    "type": "number"
                                  },
                                  "position_y": {
                                    "type": "number"
                                  }
                                }
                              }
                            },
                            "all_edges": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string"
                                  },
                                  "from_node_id": {
                                    "type": "string"
                                  },
                                  "to_node_id": {
                                    "type": "string"
                                  },
                                  "label": {
                                    "type": "string"
                                  }
                                }
                              }
                            }
                          }
                        }
                      }
                    },
                    "timestamp": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "401 Unauthorized",
                    "value": {
                      "statusCode": 401,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Invalid API key",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Lead not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "404 Not Found",
                    "value": {
                      "statusCode": 404,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Lead Bv7nC2xKs5DqYw not found in workflow Hk3pW9zQe1LmRt",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "500 Internal Server Error",
                    "value": {
                      "statusCode": 500,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Internal server error",
                      "errors": []
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "summary": "Get Lead Execution History",
        "tags": [
          "Workflow Leads"
        ],
        "description": "Returns node-by-node execution history for one workflow lead."
      }
    },
    "/v1/auth/validate": {
      "get": {
        "operationId": "validateApiKey",
        "summary": "Validate API Key",
        "description": "Checks a Bearer API key and returns its key and workspace metadata without creating resources or placing calls. Dashboard cookie sessions are not accepted.",
        "tags": [
          "Authentication"
        ],
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [],
        "responses": {
          "200": {
            "description": "Successful response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "error": {
                      "type": "boolean"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "valid": {
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "key": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string"
                            },
                            "name": {
                              "type": "string"
                            },
                            "created_at": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "expires_at": {
                              "type": "string",
                              "format": "date-time",
                              "nullable": true
                            }
                          },
                          "required": [
                            "id",
                            "name",
                            "created_at",
                            "expires_at"
                          ]
                        },
                        "organization": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "id"
                          ]
                        },
                        "access_type": {
                          "type": "string",
                          "enum": [
                            "private"
                          ]
                        }
                      },
                      "required": [
                        "valid",
                        "key",
                        "organization",
                        "access_type"
                      ]
                    },
                    "timestamp": {
                      "type": "string",
                      "format": "date-time"
                    }
                  },
                  "required": [
                    "success",
                    "error",
                    "statusCode",
                    "message",
                    "data",
                    "timestamp"
                  ]
                },
                "examples": {
                  "success": {
                    "value": {
                      "success": true,
                      "error": false,
                      "statusCode": 200,
                      "message": "Success",
                      "data": {
                        "valid": true,
                        "key": {
                          "id": "k7x2m9q4wz1abc",
                          "name": "CI Pipeline Key",
                          "created_at": "2026-01-10T08:30:00.000Z",
                          "expires_at": null
                        },
                        "organization": {
                          "id": "o14XKPP84rt22g"
                        },
                        "access_type": "private"
                      },
                      "timestamp": "2026-09-07T06:00:00.000Z"
                    }
                  }
                }
              }
            },
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "Always no-store."
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "value": {
                      "statusCode": 401,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Invalid API key",
                      "errors": []
                    }
                  },
                  "missingKey": {
                    "summary": "No Authorization header",
                    "value": {
                      "statusCode": 401,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Path not allowed for this request type",
                      "errors": []
                    }
                  },
                  "malformedHeader": {
                    "summary": "Authorization header without the Bearer scheme",
                    "value": {
                      "statusCode": 401,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "API key required",
                      "errors": []
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/agents/{id}/ivr-transfer-references": {
      "get": {
        "operationId": "listIvrTransferReferences",
        "summary": "List IVR Transfer References",
        "description": "Returns published IVR agents in this workspace that transfer to the selected agent. Use before publishing a new target version to assess affected callers.",
        "tags": [
          "Agents"
        ],
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "agent_2g7Xy3tY53gRlp"
            },
            "description": "Agent ID from List Agents."
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "error": {
                      "type": "boolean"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string",
                            "nullable": true
                          }
                        },
                        "required": [
                          "id",
                          "name"
                        ]
                      }
                    },
                    "timestamp": {
                      "type": "string",
                      "format": "date-time"
                    }
                  },
                  "required": [
                    "success",
                    "error",
                    "statusCode",
                    "message",
                    "data",
                    "timestamp"
                  ]
                },
                "examples": {
                  "success": {
                    "value": {
                      "success": true,
                      "error": false,
                      "statusCode": 200,
                      "message": "Success",
                      "data": [
                        {
                          "id": "agent_abc123",
                          "name": "Support"
                        }
                      ],
                      "timestamp": "2026-09-07T06:00:00.000Z"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "value": {
                      "statusCode": 401,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Invalid API key",
                      "errors": []
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/agents/{id}/stale-transfer-targets": {
      "get": {
        "operationId": "listStaleIvrTransferTargets",
        "summary": "List Changed IVR Transfer Targets",
        "description": "Returns targets published since this IVR agent was last published. An empty list can mean no changes, no published IVR version, or a non-IVR agent.",
        "tags": [
          "Agents"
        ],
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "agent_2g7Xy3tY53gRlp"
            },
            "description": "Agent ID from List Agents."
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "error": {
                      "type": "boolean"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string",
                            "nullable": true
                          }
                        },
                        "required": [
                          "id",
                          "name"
                        ]
                      }
                    },
                    "timestamp": {
                      "type": "string",
                      "format": "date-time"
                    }
                  },
                  "required": [
                    "success",
                    "error",
                    "statusCode",
                    "message",
                    "data",
                    "timestamp"
                  ]
                },
                "examples": {
                  "success": {
                    "value": {
                      "success": true,
                      "error": false,
                      "statusCode": 200,
                      "message": "Success",
                      "data": [
                        {
                          "id": "agent_abc123",
                          "name": "Support"
                        }
                      ],
                      "timestamp": "2026-09-07T06:00:00.000Z"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "value": {
                      "statusCode": 401,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Invalid API key",
                      "errors": []
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/agents/{id}/transfer-variables": {
      "get": {
        "operationId": "getAgentTransferVariables",
        "summary": "Get Agent Transfer Variables",
        "description": "Returns required variables and string defaults from the target agent's latest published version. Missing, deleted, unpublished, or out-of-workspace targets return empty variables and defaults.",
        "tags": [
          "Agents"
        ],
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "agent_2g7Xy3tY53gRlp"
            },
            "description": "Agent ID from List Agents."
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "error": {
                      "type": "boolean"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "variables": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "defaults": {
                          "type": "object",
                          "additionalProperties": {
                            "type": "string"
                          }
                        }
                      },
                      "required": [
                        "variables",
                        "defaults"
                      ]
                    },
                    "timestamp": {
                      "type": "string",
                      "format": "date-time"
                    }
                  },
                  "required": [
                    "success",
                    "error",
                    "statusCode",
                    "message",
                    "data",
                    "timestamp"
                  ]
                },
                "examples": {
                  "success": {
                    "value": {
                      "success": true,
                      "error": false,
                      "statusCode": 200,
                      "message": "Success",
                      "data": {
                        "variables": [
                          "customer_name"
                        ],
                        "defaults": {
                          "customer_name": "caller"
                        }
                      },
                      "timestamp": "2026-09-07T06:00:00.000Z"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "value": {
                      "statusCode": 401,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Invalid API key",
                      "errors": []
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/documents": {
      "get": {
        "operationId": "listKnowledgeBaseDocuments",
        "summary": "List Knowledge Base Documents",
        "description": "Lists non-deleted documents for the supplied knowledge base with pagination metadata.",
        "tags": [
          "Knowledge Base"
        ],
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "knowledge_base_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "example": "kb_abc123def45678"
            },
            "description": "Knowledge base ID."
          },
          {
            "name": "page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "default": 1
            },
            "description": "Page number."
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "default": 10
            },
            "description": "Documents per page."
          },
          {
            "name": "sortBy",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "default": "id"
            },
            "description": "Document field to sort by."
          },
          {
            "name": "sortOrder",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "default": "ASC"
            },
            "description": "Sort direction: ASC or DESC, in any case. Default ASC. Any other value fails with 500."
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "error": {
                      "type": "boolean"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "items": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/KnowledgeBaseDocument"
                          }
                        },
                        "meta": {
                          "type": "object",
                          "properties": {
                            "totalItems": {
                              "type": "integer"
                            },
                            "itemsPerPage": {
                              "type": "integer"
                            },
                            "totalPages": {
                              "type": "integer"
                            },
                            "currentPage": {
                              "type": "integer"
                            }
                          }
                        }
                      },
                      "required": [
                        "items",
                        "meta"
                      ]
                    },
                    "timestamp": {
                      "type": "string",
                      "format": "date-time"
                    }
                  },
                  "required": [
                    "success",
                    "error",
                    "statusCode",
                    "message",
                    "data",
                    "timestamp"
                  ]
                },
                "examples": {
                  "success": {
                    "value": {
                      "success": true,
                      "error": false,
                      "statusCode": 200,
                      "message": "Success",
                      "data": {
                        "items": [
                          {
                            "id": "Dk4mP8vQ2nLz7x",
                            "title": "Support FAQ",
                            "knowledge_base_id": "abc123def45678",
                            "description": "",
                            "content": "How do I reset my password? Open Settings and choose Reset password.",
                            "source": "",
                            "document_type": "txt",
                            "file_size": 0.0664,
                            "file_path": "knowledge-documents/abc123def45678/Support_FAQ-Dk4mP8vQ2nLz7x.txt",
                            "is_deleted": false,
                            "ingest_status": "processing",
                            "ingest_error": null,
                            "ingest_updated_at": "2026-07-03T10:30:00.000Z",
                            "ingest_job_id": "3f6c2a9e-8b1d-4e7a-9c5f-2d8e1b7a4c63"
                          }
                        ],
                        "meta": {
                          "totalItems": 1,
                          "itemsPerPage": 10,
                          "totalPages": 1,
                          "currentPage": 1
                        }
                      },
                      "timestamp": "2026-09-07T06:00:00.000Z"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "value": {
                      "statusCode": 401,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Invalid API key",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Knowledge base not found in this workspace, or it has been deleted.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "value": {
                      "statusCode": 404,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Error fetching documents: Knowledge base with ID Qm4TzR8wLp2VxN not found",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "knowledge_base_id is missing, or page or limit is a decimal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "Missing knowledge_base_id",
                    "value": {
                      "statusCode": 400,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "knowledge_base_id is required",
                      "errors": [
                        "knowledge_base_id is required"
                      ]
                    }
                  },
                  "decimal": {
                    "summary": "Decimal page",
                    "value": {
                      "statusCode": 400,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Validation failed (numeric string is expected)",
                      "errors": [
                        "Validation failed (numeric string is expected)"
                      ]
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "An unknown sortBy field, or page 0.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "Unknown sortBy",
                    "value": {
                      "statusCode": 500,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Error fetching documents: column KnowledgeDocument.bogus does not exist",
                      "errors": []
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/documents/upload": {
      "post": {
        "operationId": "uploadKnowledgeBaseDocument",
        "summary": "Upload Knowledge Base Document",
        "description": "Stores one PDF, TXT, or DOCX document and starts background indexing. Maximum 20 MB per file and 20 MB extracted text, with 25 non-deleted documents per knowledge base. A 201 response means accepted, not ready for retrieval. Poll List Knowledge Base Documents until ingest_status is ready. Titles must be unique within the knowledge base.",
        "tags": [
          "Knowledge Base"
        ],
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [],
        "responses": {
          "201": {
            "description": "Successful response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "error": {
                      "type": "boolean"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/KnowledgeBaseDocument"
                    },
                    "timestamp": {
                      "type": "string",
                      "format": "date-time"
                    }
                  },
                  "required": [
                    "success",
                    "error",
                    "statusCode",
                    "message",
                    "data",
                    "timestamp"
                  ]
                },
                "examples": {
                  "success": {
                    "value": {
                      "success": true,
                      "error": false,
                      "statusCode": 201,
                      "message": "Success",
                      "data": {
                        "id": "Dk4mP8vQ2nLz7x",
                        "title": "Support FAQ",
                        "knowledge_base_id": "abc123def45678",
                        "description": "",
                        "content": "How do I reset my password? Open Settings and choose Reset password.",
                        "source": "",
                        "document_type": "txt",
                        "file_size": 0.0664,
                        "file_path": "knowledge-documents/abc123def45678/Support_FAQ-Dk4mP8vQ2nLz7x.txt",
                        "is_deleted": false,
                        "ingest_status": "processing",
                        "ingest_error": null,
                        "ingest_updated_at": "2026-07-03T10:30:00.000Z",
                        "ingest_job_id": "3f6c2a9e-8b1d-4e7a-9c5f-2d8e1b7a4c63"
                      },
                      "timestamp": "2026-09-07T06:00:00.000Z"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Missing fields, unsupported file, or document count limit reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "value": {
                      "statusCode": 400,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Maximum limit of 25 documents reached for knowledge base ID Qm4TzR8wLp2VxN",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "value": {
                      "statusCode": 401,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Invalid API key",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Knowledge base not found in this workspace, or it has been deleted.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "value": {
                      "statusCode": 404,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Knowledge base with ID Qm4TzR8wLp2VxN not found",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "A document with this title already exists, or the knowledge base is currently indexing.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "value": {
                      "statusCode": 409,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "A document named \"Pricing FAQ\" already exists in this knowledge base",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "File exceeds 21 MB and is rejected by the upload interceptor before the handler runs. A file between 20 MB and 21 MB gets a 400 instead.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "value": {
                      "statusCode": 413,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "File too large",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Document parsing, storage, or indexing failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "value": {
                      "statusCode": 500,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Could not start indexing for this document. Please try again.",
                      "errors": []
                    }
                  }
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "file": {
                    "type": "string",
                    "format": "binary",
                    "description": "PDF, TXT, or DOCX file, at most 20 MB (20971520 bytes). Legacy DOC files are not supported."
                  },
                  "title": {
                    "type": "string",
                    "minLength": 1
                  },
                  "knowledge_base_id": {
                    "type": "string"
                  },
                  "description": {
                    "type": "string"
                  },
                  "source": {
                    "type": "string"
                  }
                },
                "required": [
                  "file",
                  "title",
                  "knowledge_base_id"
                ]
              },
              "examples": {
                "request": {
                  "value": {
                    "file": "support-faq.txt",
                    "title": "Support FAQ",
                    "knowledge_base_id": "kb_abc123def45678"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/agent-builder/classify-shape": {
      "post": {
        "operationId": "classifyAgentBlueprint",
        "summary": "Classify Agent Blueprint",
        "description": "Recommends an agent type from structured blueprint answers. No agent is created or published. Uses a model-assisted recommendation with rule-based fallback when the model is unavailable.",
        "tags": [
          "Agent Builder"
        ],
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [],
        "responses": {
          "201": {
            "description": "Successful response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "error": {
                      "type": "boolean"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "shape": {
                          "type": "string",
                          "enum": [
                            "spa",
                            "cfa",
                            "ivr"
                          ]
                        },
                        "pipeline": {
                          "type": "string",
                          "enum": [
                            "cascaded",
                            "s2s"
                          ]
                        },
                        "confidence": {
                          "type": "number",
                          "minimum": 0,
                          "maximum": 1
                        },
                        "evidence": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "needsTiebreak": {
                          "type": "boolean"
                        },
                        "features": {
                          "type": "object",
                          "additionalProperties": true
                        }
                      }
                    },
                    "timestamp": {
                      "type": "string",
                      "format": "date-time"
                    }
                  },
                  "required": [
                    "success",
                    "error",
                    "statusCode",
                    "message",
                    "data",
                    "timestamp"
                  ]
                },
                "examples": {
                  "success": {
                    "value": {
                      "success": true,
                      "error": false,
                      "statusCode": 201,
                      "message": "Success",
                      "data": {
                        "shape": "spa",
                        "pipeline": "cascaded",
                        "confidence": 0.8,
                        "evidence": [
                          "One focused call objective."
                        ],
                        "needsTiebreak": false,
                        "features": {
                          "collectCount": 2,
                          "collectIsMandatory": false,
                          "faqCount": 3,
                          "successIsProcedural": false,
                          "hasRoutingIntent": false,
                          "hasProcedureIntent": false,
                          "hasJudgementIntent": true,
                          "wantsNaturalness": true,
                          "hasComplianceConstraint": false,
                          "languageIsEnglish": true,
                          "decisionPointCount": 0
                        }
                      },
                      "timestamp": "2026-09-07T06:00:00.000Z"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "A blueprint field has an invalid type or exceeds its length limit.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "value": {
                      "statusCode": 400,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "primary_goal must be shorter than or equal to 4000 characters",
                      "errors": [
                        "primary_goal must be shorter than or equal to 4000 characters"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "value": {
                      "statusCode": 401,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Invalid API key",
                      "errors": []
                    }
                  }
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "company_and_offering": {
                    "type": "string",
                    "maxLength": 4000
                  },
                  "target_customer": {
                    "type": "string",
                    "maxLength": 4000
                  },
                  "primary_goal": {
                    "type": "string",
                    "maxLength": 4000
                  },
                  "success_criteria": {
                    "type": "string",
                    "maxLength": 4000
                  },
                  "information_to_collect": {
                    "type": "string",
                    "maxLength": 4000
                  },
                  "objections_and_faqs": {
                    "type": "string",
                    "maxLength": 4000
                  },
                  "agent_tone": {
                    "type": "string",
                    "maxLength": 4000
                  },
                  "additional_context": {
                    "type": "string",
                    "maxLength": 4000
                  },
                  "language": {
                    "type": "string",
                    "maxLength": 120
                  }
                }
              },
              "examples": {
                "request": {
                  "value": {
                    "primary_goal": "Book a callback",
                    "language": "English"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/agent-builder/shape-advisor": {
      "post": {
        "operationId": "recommendAgentType",
        "summary": "Recommend Agent Type",
        "description": "Recommends an agent type, a two-agent combination, or a clarifying question from a plain-language description. No agent is created or published.",
        "tags": [
          "Agent Builder"
        ],
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [],
        "responses": {
          "201": {
            "description": "Successful response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "error": {
                      "type": "boolean"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "shape": {
                          "type": "string",
                          "nullable": true
                        },
                        "agent_type": {
                          "type": "string",
                          "nullable": true
                        },
                        "pipeline": {
                          "type": "string",
                          "enum": [
                            "Cascaded",
                            "Speech_To_Speech"
                          ]
                        },
                        "combo": {
                          "type": "object",
                          "properties": {
                            "front": {
                              "type": "string"
                            },
                            "then": {
                              "type": "string"
                            }
                          },
                          "nullable": true
                        },
                        "clarify": {
                          "type": "string",
                          "nullable": true
                        },
                        "why": {
                          "type": "string"
                        }
                      }
                    },
                    "timestamp": {
                      "type": "string",
                      "format": "date-time"
                    }
                  },
                  "required": [
                    "success",
                    "error",
                    "statusCode",
                    "message",
                    "data",
                    "timestamp"
                  ]
                },
                "examples": {
                  "success": {
                    "value": {
                      "success": true,
                      "error": false,
                      "statusCode": 201,
                      "message": "Success",
                      "data": {
                        "shape": "spa",
                        "agent_type": "Single_Prompt_Agent",
                        "pipeline": "Cascaded",
                        "combo": null,
                        "clarify": null,
                        "why": "One focused conversation can handle this goal."
                      },
                      "timestamp": "2026-09-07T06:00:00.000Z"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Description is missing, has an invalid type, or exceeds 2000 characters.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "value": {
                      "statusCode": 400,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "description must be shorter than or equal to 2000 characters",
                      "errors": [
                        "description must be shorter than or equal to 2000 characters"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "value": {
                      "statusCode": 401,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Invalid API key",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "The recommendation could not be generated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "value": {
                      "statusCode": 500,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Internal server error",
                      "errors": []
                    }
                  }
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "description": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 2000
                  }
                },
                "required": [
                  "description"
                ]
              },
              "examples": {
                "request": {
                  "value": {
                    "description": "Call new customers and book a callback."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/agent-builder/inventory": {
      "get": {
        "operationId": "getAgentBuilderInventory",
        "parameters": [],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "error",
                    "statusCode",
                    "message",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "statusCode": {
                      "type": "integer",
                      "example": 200
                    },
                    "message": {
                      "type": "string",
                      "example": "Success"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "llms": {
                          "type": "array",
                          "description": "LLMs, each with an unprefixed id, name and model_category.",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "name": {
                                "type": "string"
                              },
                              "model_category": {
                                "type": "string"
                              }
                            }
                          }
                        },
                        "transcribers": {
                          "type": "array",
                          "description": "Transcribers, each with an unprefixed id, name, provider and model_id.",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "name": {
                                "type": "string"
                              },
                              "provider": {
                                "type": "string"
                              },
                              "model_id": {
                                "type": "string"
                              }
                            }
                          }
                        },
                        "languages": {
                          "type": "array",
                          "description": "Languages, each with an unprefixed id, name and code.",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "name": {
                                "type": "string"
                              },
                              "code": {
                                "type": "string"
                              }
                            }
                          }
                        }
                      },
                      "required": [
                        "llms",
                        "transcribers",
                        "languages"
                      ],
                      "additionalProperties": false
                    },
                    "timestamp": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, expired, or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "401 error",
                    "value": {
                      "statusCode": 401,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Invalid API key",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "The request could not be completed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "Server error",
                    "value": {
                      "statusCode": 500,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Internal server error",
                      "errors": []
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "summary": "Get Agent Builder Inventory",
        "tags": [
          "Agent Builder"
        ],
        "description": "Returns the model, transcriber, and language catalog the builder resolves a configuration from. IDs are unprefixed. The catalog is not filtered to your workspace: it lists at most 100 primary LLMs."
      }
    },
    "/v1/agent-builder/run": {
      "post": {
        "description": "Generates a draft configuration from structured answers. This operation does not save or publish an agent. A build can take longer than the 60 second HTTP timeout; use Stream Agent Build for long builds.",
        "operationId": "runAgentBuilder",
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RunAgentBuilder"
              },
              "examples": {
                "request": {
                  "value": {
                    "structured_input": {
                      "company_and_offering": {
                        "description": "Company and offering",
                        "value": "Acme provides appointment scheduling software."
                      },
                      "target_customer": {
                        "description": "Target customer",
                        "value": "Small business owners who requested a demo."
                      },
                      "primary_goal": {
                        "description": "Call goal",
                        "value": "Arrange a product demo."
                      },
                      "success_criteria": {
                        "description": "Success criteria",
                        "value": "Confirm interest and a preferred callback time."
                      },
                      "information_to_collect": {
                        "description": "Information to collect",
                        "value": "Name and preferred callback time."
                      },
                      "objections_and_faqs": {
                        "description": "Questions",
                        "value": "Explain that the demo is free."
                      },
                      "agent_tone": {
                        "description": "Tone",
                        "value": "Friendly, concise, and professional."
                      },
                      "additional_context": {
                        "description": "Context",
                        "value": "Do not promise pricing or unavailable appointment slots."
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Builder run completed or needs more input",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "error",
                    "statusCode",
                    "message",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "statusCode": {
                      "type": "integer",
                      "example": 201
                    },
                    "message": {
                      "type": "string",
                      "example": "Success"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "organizationId": {
                          "type": "string"
                        },
                        "structuredInput": {
                          "type": "object",
                          "properties": {
                            "company_and_offering": {
                              "type": "object",
                              "properties": {
                                "description": {
                                  "type": "string"
                                },
                                "value": {
                                  "type": "string"
                                }
                              },
                              "required": [
                                "description",
                                "value"
                              ]
                            },
                            "target_customer": {
                              "type": "object",
                              "properties": {
                                "description": {
                                  "type": "string"
                                },
                                "value": {
                                  "type": "string"
                                }
                              },
                              "required": [
                                "description",
                                "value"
                              ]
                            },
                            "primary_goal": {
                              "type": "object",
                              "properties": {
                                "description": {
                                  "type": "string"
                                },
                                "value": {
                                  "type": "string"
                                }
                              },
                              "required": [
                                "description",
                                "value"
                              ]
                            },
                            "success_criteria": {
                              "type": "object",
                              "properties": {
                                "description": {
                                  "type": "string"
                                },
                                "value": {
                                  "type": "string"
                                }
                              },
                              "required": [
                                "description",
                                "value"
                              ]
                            },
                            "information_to_collect": {
                              "type": "object",
                              "properties": {
                                "description": {
                                  "type": "string"
                                },
                                "value": {
                                  "type": "string"
                                }
                              },
                              "required": [
                                "description",
                                "value"
                              ]
                            },
                            "objections_and_faqs": {
                              "type": "object",
                              "properties": {
                                "description": {
                                  "type": "string"
                                },
                                "value": {
                                  "type": "string"
                                }
                              },
                              "required": [
                                "description",
                                "value"
                              ]
                            },
                            "agent_tone": {
                              "type": "object",
                              "properties": {
                                "description": {
                                  "type": "string"
                                },
                                "value": {
                                  "type": "string"
                                }
                              },
                              "required": [
                                "description",
                                "value"
                              ]
                            },
                            "additional_context": {
                              "type": "object",
                              "properties": {
                                "description": {
                                  "type": "string"
                                },
                                "value": {
                                  "type": "string"
                                }
                              },
                              "required": [
                                "description",
                                "value"
                              ]
                            },
                            "validation_clarifications": {
                              "type": "object",
                              "properties": {
                                "description": {
                                  "type": "string"
                                },
                                "value": {
                                  "type": "string"
                                }
                              },
                              "required": [
                                "description",
                                "value"
                              ]
                            }
                          },
                          "required": [
                            "company_and_offering",
                            "target_customer",
                            "primary_goal",
                            "success_criteria",
                            "information_to_collect",
                            "objections_and_faqs",
                            "agent_tone",
                            "additional_context"
                          ]
                        },
                        "pipeline": {
                          "type": "string",
                          "enum": [
                            "cascaded",
                            "s2s"
                          ]
                        },
                        "targetShape": {
                          "type": "string",
                          "enum": [
                            "spa",
                            "cfa",
                            "ivr"
                          ]
                        },
                        "buildAttempt": {
                          "type": "number"
                        },
                        "maxBuildAttempts": {
                          "type": "number"
                        },
                        "agentBrief": {
                          "type": "object",
                          "properties": {
                            "agent_name": {
                              "type": "string"
                            },
                            "company_name": {
                              "type": "string"
                            },
                            "agent_role": {
                              "type": "string"
                            },
                            "tone": {
                              "type": "string"
                            },
                            "language_rules": {
                              "type": "string"
                            },
                            "caller_type": {
                              "type": "string"
                            },
                            "call_type": {
                              "type": "string"
                            },
                            "primary_goal": {
                              "type": "string"
                            },
                            "secondary_goals": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "known_variables": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "available_context": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "required_information_to_collect": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "call_flow_steps": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "guardrails": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "special_rules": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "faqs": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "objections": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "success_criteria": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "failure_criteria": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "post_call_fields_requested": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "known_terms": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "unknowns_or_missing_info": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            }
                          },
                          "required": [
                            "agent_name",
                            "company_name",
                            "agent_role",
                            "tone",
                            "language_rules",
                            "caller_type",
                            "call_type",
                            "primary_goal",
                            "secondary_goals",
                            "known_variables",
                            "available_context",
                            "required_information_to_collect",
                            "call_flow_steps",
                            "guardrails",
                            "special_rules",
                            "faqs",
                            "objections",
                            "success_criteria",
                            "failure_criteria",
                            "post_call_fields_requested",
                            "known_terms",
                            "unknowns_or_missing_info"
                          ],
                          "nullable": true
                        },
                        "voicePreferences": {
                          "type": "object",
                          "properties": {
                            "language": {
                              "type": "string"
                            },
                            "accent": {
                              "type": "string"
                            },
                            "gender": {
                              "type": "string"
                            },
                            "keywords": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            }
                          },
                          "required": [
                            "language",
                            "accent",
                            "gender",
                            "keywords"
                          ],
                          "nullable": true
                        },
                        "missingQuestions": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "inventory": {
                          "type": "object",
                          "properties": {
                            "llms": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string"
                                  },
                                  "name": {
                                    "type": "string"
                                  },
                                  "model_category": {
                                    "type": "string"
                                  }
                                },
                                "required": [
                                  "id",
                                  "name"
                                ]
                              }
                            },
                            "transcribers": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string"
                                  },
                                  "name": {
                                    "type": "string"
                                  },
                                  "provider": {
                                    "type": "string"
                                  },
                                  "model_id": {
                                    "type": "string"
                                  }
                                },
                                "required": [
                                  "id",
                                  "name",
                                  "provider",
                                  "model_id"
                                ]
                              }
                            },
                            "languages": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string"
                                  },
                                  "name": {
                                    "type": "string"
                                  },
                                  "code": {
                                    "type": "string"
                                  }
                                },
                                "required": [
                                  "id",
                                  "name",
                                  "code"
                                ]
                              }
                            }
                          },
                          "required": [
                            "llms",
                            "transcribers",
                            "languages"
                          ],
                          "nullable": true
                        },
                        "technicalProfile": {
                          "type": "object",
                          "properties": {
                            "agent_type": {
                              "type": "string",
                              "enum": [
                                "Single_Prompt_Agent",
                                "Conversational_Flow_Agent",
                                "IVR_Agent"
                              ]
                            },
                            "pipeline_type": {
                              "type": "string",
                              "enum": [
                                "Cascaded",
                                "Speech_To_Speech"
                              ]
                            },
                            "llm_id": {
                              "type": "string",
                              "nullable": true
                            },
                            "llm_name": {
                              "type": "string",
                              "nullable": true
                            },
                            "voice_id": {
                              "type": "string",
                              "nullable": true
                            },
                            "voice_name": {
                              "type": "string",
                              "nullable": true
                            },
                            "voice_model_id": {
                              "type": "string",
                              "nullable": true
                            },
                            "transcriber_id": {
                              "type": "string",
                              "nullable": true
                            },
                            "transcriber_name": {
                              "type": "string",
                              "nullable": true
                            },
                            "language_id": {
                              "type": "string",
                              "nullable": true
                            },
                            "language_code": {
                              "type": "string",
                              "nullable": true
                            },
                            "boosted_keywords": {
                              "type": "string",
                              "nullable": true
                            },
                            "fallback_stt_enabled": {
                              "type": "boolean"
                            },
                            "stt_fallback_transcriber_id": {
                              "type": "string",
                              "nullable": true
                            },
                            "stt_fallback_wait_ms": {
                              "type": "number"
                            },
                            "audio_cache_enabled": {
                              "type": "boolean"
                            },
                            "denoising_mode": {
                              "type": "string",
                              "enum": [
                                "remove_noise",
                                "remove_noise_and_speech"
                              ]
                            },
                            "max_call_duration_sec": {
                              "type": "number"
                            },
                            "system_prompt_text": {
                              "type": "string"
                            },
                            "llm_temperature": {
                              "type": "number"
                            },
                            "fallback_llm_enabled": {
                              "type": "boolean"
                            },
                            "llm_fallback_model": {
                              "type": "string",
                              "nullable": true
                            },
                            "llm_fallback_model_name": {
                              "type": "string",
                              "nullable": true
                            },
                            "llm_fallback_delay_ms": {
                              "type": "number"
                            },
                            "optimization_summary": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "agent_type",
                            "pipeline_type",
                            "llm_id",
                            "llm_name",
                            "voice_id",
                            "voice_name",
                            "voice_model_id",
                            "transcriber_id",
                            "transcriber_name",
                            "language_id",
                            "language_code",
                            "boosted_keywords",
                            "fallback_stt_enabled",
                            "stt_fallback_transcriber_id",
                            "stt_fallback_wait_ms",
                            "audio_cache_enabled",
                            "denoising_mode",
                            "max_call_duration_sec",
                            "system_prompt_text",
                            "llm_temperature",
                            "fallback_llm_enabled",
                            "llm_fallback_model",
                            "llm_fallback_model_name",
                            "llm_fallback_delay_ms",
                            "optimization_summary"
                          ],
                          "nullable": true
                        },
                        "promptSections": {
                          "type": "object",
                          "properties": {
                            "identity": {
                              "type": "string"
                            },
                            "context_and_variables": {
                              "type": "string"
                            },
                            "primary_goal": {
                              "type": "string"
                            },
                            "call_flow": {
                              "type": "string"
                            },
                            "guardrails": {
                              "type": "string"
                            },
                            "faqs_and_objections": {
                              "type": "string"
                            },
                            "closing_rules": {
                              "type": "string"
                            },
                            "ai_identity_if_asked": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "identity",
                            "context_and_variables",
                            "primary_goal",
                            "call_flow",
                            "guardrails",
                            "faqs_and_objections",
                            "closing_rules",
                            "ai_identity_if_asked"
                          ],
                          "nullable": true
                        },
                        "promptText": {
                          "type": "string",
                          "nullable": true
                        },
                        "welcomeMessage": {
                          "type": "string",
                          "nullable": true
                        },
                        "postcallAnalysis": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "field_name": {
                                "type": "string"
                              },
                              "field_type": {
                                "type": "string",
                                "enum": [
                                  "TEXT",
                                  "SELECTOR",
                                  "BOOLEAN",
                                  "NUMBER"
                                ]
                              },
                              "field_description": {
                                "type": "string"
                              },
                              "additional_fields": {
                                "type": "object",
                                "additionalProperties": {}
                              }
                            },
                            "required": [
                              "field_name",
                              "field_type",
                              "field_description"
                            ]
                          }
                        },
                        "boostedKeywords": {
                          "type": "string",
                          "nullable": true
                        },
                        "simulations": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "evaluation": {
                          "type": "object",
                          "properties": {
                            "overall_pass": {
                              "type": "boolean"
                            },
                            "prompt_score": {
                              "type": "number"
                            },
                            "conversation_score": {
                              "type": "number"
                            },
                            "pca_score": {
                              "type": "number"
                            },
                            "technical_fit_score": {
                              "type": "number"
                            },
                            "issues": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "prompt_fixes": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "pca_fixes": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "technical_profile_fixes": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "human_review_required": {
                              "type": "boolean"
                            },
                            "summary": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "overall_pass",
                            "prompt_score",
                            "conversation_score",
                            "pca_score",
                            "technical_fit_score",
                            "issues",
                            "prompt_fixes",
                            "pca_fixes",
                            "technical_profile_fixes",
                            "human_review_required",
                            "summary"
                          ],
                          "nullable": true
                        },
                        "draftAgent": {
                          "type": "object",
                          "properties": {
                            "agent_type": {
                              "type": "string",
                              "enum": [
                                "Single_Prompt_Agent",
                                "Conversational_Flow_Agent",
                                "IVR_Agent"
                              ]
                            },
                            "pipeline_type": {
                              "type": "string",
                              "enum": [
                                "Cascaded",
                                "Speech_To_Speech"
                              ]
                            },
                            "ivr_menu": {
                              "type": "object",
                              "additionalProperties": {},
                              "nullable": true
                            },
                            "agent_identity": {
                              "type": "string",
                              "nullable": true
                            },
                            "agent_background": {
                              "type": "string",
                              "nullable": true
                            },
                            "node_positions": {
                              "type": "string",
                              "nullable": true
                            },
                            "title": {
                              "type": "string"
                            },
                            "description": {
                              "type": "string"
                            },
                            "prompt_text": {
                              "type": "string"
                            },
                            "system_prompt_text": {
                              "type": "string"
                            },
                            "welcome_message": {
                              "type": "string"
                            },
                            "default_dynamic_variables": {
                              "type": "object",
                              "additionalProperties": {
                                "type": "string"
                              }
                            },
                            "postcall_analysis": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "field_name": {
                                    "type": "string"
                                  },
                                  "field_type": {
                                    "type": "string",
                                    "enum": [
                                      "TEXT",
                                      "SELECTOR",
                                      "BOOLEAN",
                                      "NUMBER"
                                    ]
                                  },
                                  "field_description": {
                                    "type": "string"
                                  },
                                  "additional_fields": {
                                    "type": "object",
                                    "additionalProperties": {}
                                  }
                                },
                                "required": [
                                  "field_name",
                                  "field_type",
                                  "field_description"
                                ]
                              }
                            },
                            "llm_id": {
                              "type": "string",
                              "nullable": true
                            },
                            "voice_id": {
                              "type": "string",
                              "nullable": true
                            },
                            "voice_model_id": {
                              "type": "string",
                              "nullable": true
                            },
                            "transcriber_id": {
                              "type": "string",
                              "nullable": true
                            },
                            "language_id": {
                              "type": "string",
                              "nullable": true
                            },
                            "boosted_keywords": {
                              "type": "string",
                              "nullable": true
                            },
                            "conversation_start_type": {
                              "type": "string"
                            },
                            "llm_temperature": {
                              "type": "number"
                            },
                            "fallback_llm_enabled": {
                              "type": "boolean"
                            },
                            "llm_fallback_model": {
                              "type": "string",
                              "nullable": true
                            },
                            "llm_fallback_delay_ms": {
                              "type": "number"
                            },
                            "fallback_stt_enabled": {
                              "type": "boolean"
                            },
                            "stt_fallback_transcriber_id": {
                              "type": "string",
                              "nullable": true
                            },
                            "stt_fallback_wait_ms": {
                              "type": "number"
                            },
                            "audio_cache_enabled": {
                              "type": "boolean"
                            },
                            "denoising_mode": {
                              "type": "string",
                              "enum": [
                                "remove_noise",
                                "remove_noise_and_speech"
                              ]
                            },
                            "max_call_duration_sec": {
                              "type": "number"
                            }
                          },
                          "required": [
                            "agent_type",
                            "pipeline_type",
                            "ivr_menu",
                            "agent_identity",
                            "agent_background",
                            "node_positions",
                            "title",
                            "description",
                            "prompt_text",
                            "system_prompt_text",
                            "welcome_message",
                            "default_dynamic_variables",
                            "postcall_analysis",
                            "llm_id",
                            "voice_id",
                            "voice_model_id",
                            "transcriber_id",
                            "language_id",
                            "boosted_keywords",
                            "conversation_start_type",
                            "llm_temperature",
                            "fallback_llm_enabled",
                            "llm_fallback_model",
                            "llm_fallback_delay_ms",
                            "fallback_stt_enabled",
                            "stt_fallback_transcriber_id",
                            "stt_fallback_wait_ms",
                            "audio_cache_enabled",
                            "denoising_mode",
                            "max_call_duration_sec"
                          ],
                          "nullable": true
                        },
                        "events": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "node": {
                                "type": "string"
                              },
                              "status": {
                                "type": "string",
                                "enum": [
                                  "started",
                                  "completed",
                                  "failed"
                                ]
                              },
                              "message": {
                                "type": "string"
                              },
                              "timestamp": {
                                "type": "string"
                              },
                              "artifact": {
                                "type": "object",
                                "additionalProperties": {}
                              }
                            },
                            "required": [
                              "node",
                              "status",
                              "message",
                              "timestamp"
                            ]
                          }
                        },
                        "status": {
                          "type": "string",
                          "enum": [
                            "needs_input",
                            "completed",
                            "human_review",
                            "failed"
                          ]
                        },
                        "error": {
                          "type": "string",
                          "nullable": true
                        }
                      },
                      "required": [
                        "organizationId",
                        "structuredInput",
                        "pipeline",
                        "targetShape",
                        "buildAttempt",
                        "maxBuildAttempts",
                        "agentBrief",
                        "voicePreferences",
                        "missingQuestions",
                        "inventory",
                        "technicalProfile",
                        "promptSections",
                        "promptText",
                        "welcomeMessage",
                        "postcallAnalysis",
                        "boostedKeywords",
                        "simulations",
                        "evaluation",
                        "draftAgent",
                        "events",
                        "status",
                        "error"
                      ]
                    },
                    "timestamp": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, expired, or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "401 error",
                    "value": {
                      "statusCode": 401,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Invalid API key",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "The body failed validation, for example build_attempt outside 1 to 2 or an unknown pipeline.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "Invalid body",
                    "value": {
                      "statusCode": 400,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "build_attempt must not be greater than 2, pipeline must be one of the following values: cascaded, s2s",
                      "errors": [
                        "build_attempt must not be greater than 2",
                        "pipeline must be one of the following values: cascaded, s2s"
                      ]
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "The request could not be completed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "Server error",
                    "value": {
                      "statusCode": 500,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Internal server error",
                      "errors": []
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "summary": "Build Agent Configuration",
        "tags": [
          "Agent Builder"
        ]
      }
    },
    "/v1/agent-builder/run/stream": {
      "post": {
        "description": "Streams build progress as newline-delimited JSON and returns the generated draft configuration without saving or publishing an agent.",
        "operationId": "streamAgentBuilder",
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RunAgentBuilder"
              },
              "examples": {
                "request": {
                  "value": {
                    "structured_input": {
                      "company_and_offering": {
                        "description": "Company and offering",
                        "value": "Acme provides appointment scheduling software."
                      },
                      "target_customer": {
                        "description": "Target customer",
                        "value": "Small business owners who requested a demo."
                      },
                      "primary_goal": {
                        "description": "Call goal",
                        "value": "Arrange a product demo."
                      },
                      "success_criteria": {
                        "description": "Success criteria",
                        "value": "Confirm interest and a preferred callback time."
                      },
                      "information_to_collect": {
                        "description": "Information to collect",
                        "value": "Name and preferred callback time."
                      },
                      "objections_and_faqs": {
                        "description": "Questions",
                        "value": "Explain that the demo is free."
                      },
                      "agent_tone": {
                        "description": "Tone",
                        "value": "Friendly, concise, and professional."
                      },
                      "additional_context": {
                        "description": "Context",
                        "value": "Do not promise pricing or unavailable appointment slots."
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "NDJSON stream of thinking updates and final result",
            "content": {
              "application/x-ndjson": {
                "schema": {
                  "type": "string",
                  "description": "One JSON object per line. Event types: phase_start, phase_complete, thinking_delta, building_event, complete, error. The complete event contains data with status, events, missingQuestions, evaluation, draftAgent, promptText, welcomeMessage, technicalProfile, and error."
                },
                "example": "{\"type\":\"phase_start\",\"phase\":\"thinking\"}\n{\"type\":\"thinking_delta\",\"delta\":\"Reading your requirements\",\"label\":\"Understanding your needs\",\"phase\":\"thinking\"}\n"
              }
            }
          },
          "401": {
            "description": "Missing, expired, or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "401 error",
                    "value": {
                      "statusCode": 401,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Invalid API key",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "The body failed validation, for example build_attempt outside 1 to 2 or an unknown pipeline.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "Invalid body",
                    "value": {
                      "statusCode": 400,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "build_attempt must not be greater than 2, pipeline must be one of the following values: cascaded, s2s",
                      "errors": [
                        "build_attempt must not be greater than 2",
                        "pipeline must be one of the following values: cascaded, s2s"
                      ]
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "The request could not be completed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "Server error",
                    "value": {
                      "statusCode": 500,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Internal server error",
                      "errors": []
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "summary": "Stream Agent Build",
        "tags": [
          "Agent Builder"
        ]
      }
    },
    "/v1/agent-builder/generate-objectives": {
      "post": {
        "description": "Drafts call objectives from your company and customer context without changing an agent.",
        "operationId": "generateAgentObjectives",
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/GenerateObjectives"
              },
              "examples": {
                "request": {
                  "value": {
                    "company_and_offering": "Acme Corp - B2B payroll software for mid-market HR teams.",
                    "target_customer": "HR directors at 200-2,000 employee companies evaluating payroll vendors.",
                    "primary_goal": "Book demos and answer pricing and onboarding questions."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Generated objectives fields",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "error",
                    "statusCode",
                    "message",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "statusCode": {
                      "type": "integer",
                      "example": 201
                    },
                    "message": {
                      "type": "string",
                      "example": "Success"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "success_criteria": {
                          "type": "string"
                        },
                        "information_to_collect": {
                          "type": "string"
                        },
                        "objections_and_faqs": {
                          "type": "string"
                        }
                      }
                    },
                    "timestamp": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, expired, or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "401 error",
                    "value": {
                      "statusCode": 401,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Invalid API key",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "A field is missing or empty, the context is too thin to draft objectives, or no success criteria could be generated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "notEnoughContext": {
                    "summary": "400 error",
                    "value": {
                      "statusCode": 400,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "The given information does not contain enough details to build an agent. Tell us what you offer, who you serve, and what the agent should do.",
                      "errors": [
                        "The given information does not contain enough details to build an agent. Tell us what you offer, who you serve, and what the agent should do."
                      ]
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "The request could not be completed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "Server error",
                    "value": {
                      "statusCode": 500,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Internal server error",
                      "errors": []
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "summary": "Generate Agent Objectives",
        "tags": [
          "Agent Builder"
        ]
      }
    },
    "/v1/agent-builder/generate-agent-tone": {
      "post": {
        "description": "Drafts an agent tone and inferred locale from the supplied context without changing an agent.",
        "operationId": "generateAgentTone",
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/GenerateAgentTone"
              },
              "examples": {
                "request": {
                  "value": {
                    "company_and_offering": "Example company and offering",
                    "target_customer": "Example target customer",
                    "primary_goal": "Example primary goal",
                    "success_criteria": "Example success criteria",
                    "information_to_collect": "Example information to collect",
                    "objections_and_faqs": "Example objections and faqs"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Generated agent tone",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "error",
                    "statusCode",
                    "message",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "statusCode": {
                      "type": "integer",
                      "example": 201
                    },
                    "message": {
                      "type": "string",
                      "example": "Success"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "agent_tone": {
                          "type": "string"
                        },
                        "inferred_region": {
                          "type": "string"
                        },
                        "inferred_language": {
                          "type": "string"
                        }
                      }
                    },
                    "timestamp": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, expired, or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "401 error",
                    "value": {
                      "statusCode": 401,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Invalid API key",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "A field is missing, a required field is empty, or no tone could be generated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "noTone": {
                    "summary": "400 error",
                    "value": {
                      "statusCode": 400,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Could not generate agent tone from intake context",
                      "errors": [
                        "Could not generate agent tone from intake context"
                      ]
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "The request could not be completed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "Server error",
                    "value": {
                      "statusCode": 500,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Internal server error",
                      "errors": []
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "summary": "Generate Agent Tone",
        "tags": [
          "Agent Builder"
        ]
      }
    },
    "/v1/agent-versions/{agentId}/version/{versionNumber}": {
      "get": {
        "operationId": "getAgentVersion",
        "parameters": [
          {
            "name": "agentId",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "versionNumber",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "error",
                    "statusCode",
                    "message",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "statusCode": {
                      "type": "integer",
                      "example": 200
                    },
                    "message": {
                      "type": "string",
                      "example": "Success"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "agent_id": {
                          "type": "string"
                        },
                        "version_number": {
                          "type": "string",
                          "example": "1",
                          "description": "Version number. Serialized as a string (the column is a 64-bit integer)."
                        },
                        "version_title": {
                          "type": "string",
                          "nullable": true
                        },
                        "title": {
                          "type": "string",
                          "nullable": true
                        },
                        "description": {
                          "type": "string",
                          "nullable": true
                        },
                        "llm_id": {
                          "type": "string",
                          "nullable": true
                        },
                        "language_id": {
                          "type": "string"
                        },
                        "voice_id": {
                          "type": "string"
                        },
                        "voice_model_id": {
                          "type": "string",
                          "nullable": true
                        },
                        "voice_speed": {
                          "type": "number",
                          "nullable": true
                        },
                        "voice_temperature": {
                          "type": "number",
                          "nullable": true
                        },
                        "voice_volume": {
                          "type": "number",
                          "nullable": true
                        },
                        "voice_pitch": {
                          "type": "number",
                          "nullable": true
                        },
                        "prompt_text": {
                          "type": "string"
                        },
                        "system_prompt_text": {
                          "type": "string",
                          "nullable": true
                        },
                        "conversation_start_type": {
                          "type": "string"
                        },
                        "welcome_message": {
                          "type": "string",
                          "nullable": true
                        },
                        "knowledge_base_ids": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          },
                          "nullable": true
                        },
                        "kb_max_chunks": {
                          "type": "number",
                          "nullable": true
                        },
                        "kb_min_score": {
                          "type": "number",
                          "nullable": true
                        },
                        "is_published": {
                          "type": "boolean"
                        },
                        "voicemail_detection": {
                          "type": "boolean",
                          "nullable": true
                        },
                        "hangup_on_voicemail": {
                          "type": "boolean",
                          "nullable": true
                        },
                        "voicemail_message": {
                          "type": "string",
                          "nullable": true
                        },
                        "end_call_on_silence_sec": {
                          "type": "number"
                        },
                        "max_call_duration_sec": {
                          "type": "number"
                        },
                        "ring_duration_sec": {
                          "type": "number"
                        },
                        "background_sound": {
                          "type": "string",
                          "nullable": true
                        },
                        "ambient_noise": {
                          "type": "boolean"
                        },
                        "background_sound_volume": {
                          "type": "number"
                        },
                        "llm_temperature": {
                          "type": "number"
                        },
                        "fallback_llm_enabled": {
                          "type": "boolean",
                          "nullable": true
                        },
                        "llm_fallback_delay_ms": {
                          "type": "number",
                          "nullable": true
                        },
                        "llm_fallback_model": {
                          "type": "string",
                          "nullable": true
                        },
                        "fallback_stt_enabled": {
                          "type": "boolean",
                          "nullable": true
                        },
                        "stt_fallback_wait_ms": {
                          "type": "number",
                          "nullable": true
                        },
                        "stt_fallback_transcriber_id": {
                          "type": "string",
                          "nullable": true
                        },
                        "predictive_preprocessing_enabled": {
                          "type": "boolean",
                          "nullable": true
                        },
                        "prompt_caching_enabled": {
                          "type": "boolean",
                          "nullable": true
                        },
                        "responsiveness": {
                          "type": "number"
                        },
                        "interruption_sensitivity": {
                          "type": "number"
                        },
                        "response_eagerness": {
                          "type": "number"
                        },
                        "transcriber_id": {
                          "type": "string",
                          "nullable": true
                        },
                        "denoising_mode": {
                          "type": "string",
                          "nullable": true
                        },
                        "denoise_strength": {
                          "type": "number",
                          "nullable": true
                        },
                        "boosted_keywords": {
                          "type": "string",
                          "nullable": true
                        },
                        "boost_dynamic_variables": {
                          "type": "boolean",
                          "nullable": true
                        },
                        "reminder_message_interval": {
                          "type": "number",
                          "nullable": true
                        },
                        "reminder_message_content": {
                          "type": "string",
                          "nullable": true
                        },
                        "default_dynamic_variables": {
                          "nullable": true
                        },
                        "call_transfer_settings": {
                          "nullable": true
                        },
                        "agent_identity": {
                          "type": "string",
                          "nullable": true
                        },
                        "agent_background": {
                          "type": "string",
                          "nullable": true
                        },
                        "node_positions": {
                          "type": "string",
                          "nullable": true
                        },
                        "ivr_menu": {
                          "type": "object",
                          "additionalProperties": true,
                          "nullable": true
                        },
                        "audio_cache_enabled": {
                          "type": "boolean",
                          "nullable": true
                        },
                        "agent": {
                          "type": "object",
                          "nullable": true,
                          "additionalProperties": true,
                          "description": "Associated resource when configured. Included record; its own IDs are unprefixed."
                        },
                        "language": {
                          "type": "object",
                          "nullable": true,
                          "additionalProperties": true,
                          "description": "Associated resource when configured. Included record; its own IDs are unprefixed."
                        },
                        "voice": {
                          "type": "object",
                          "nullable": true,
                          "additionalProperties": true,
                          "description": "Associated resource when configured. Included record; its own IDs are unprefixed."
                        },
                        "llm": {
                          "type": "object",
                          "nullable": true,
                          "additionalProperties": true,
                          "description": "Associated resource when configured. Included record; its own IDs are unprefixed."
                        },
                        "transcriber": {
                          "type": "object",
                          "nullable": true,
                          "additionalProperties": true,
                          "description": "Associated resource when configured. Included record; its own IDs are unprefixed."
                        },
                        "sttFallbackTranscriber": {
                          "type": "object",
                          "nullable": true,
                          "additionalProperties": true,
                          "description": "Associated resource when configured. Included record; its own IDs are unprefixed."
                        },
                        "voiceModel": {
                          "type": "object",
                          "nullable": true,
                          "additionalProperties": true,
                          "description": "Associated resource when configured. Included record; its own IDs are unprefixed."
                        },
                        "createdAt": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "updatedAt": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "end_call_on_hold_sec": {
                          "type": "integer",
                          "nullable": true,
                          "description": "Seconds to wait in a confirmed hold before hanging up; null when disabled."
                        },
                        "language_default_message": {
                          "type": "string",
                          "nullable": true,
                          "description": "Message spoken when the caller language is not supported."
                        },
                        "prompt_tokens": {
                          "type": "integer",
                          "nullable": true,
                          "description": "Token count of the stored prompt, when computed."
                        },
                        "secondary_language_ids": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          },
                          "description": "Additional language IDs the version can switch to."
                        },
                        "speech_to_speech_english_accent": {
                          "type": "string",
                          "enum": [
                            "indian",
                            "british",
                            "american"
                          ],
                          "description": "Accent of the agent's English on Speech-to-Speech calls: indian (default), british or american."
                        }
                      }
                    },
                    "timestamp": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, expired, or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "401 error",
                    "value": {
                      "statusCode": 401,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Invalid API key",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "The agent version does not exist in the authenticated workspace.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "404 error",
                    "value": {
                      "statusCode": 404,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Version 3 not found for agent ID 2g7Xy3tY53gRlp",
                      "errors": []
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "tags": [
          "Agents"
        ],
        "summary": "Get Agent Version",
        "description": "Returns one version of an agent owned by your workspace. Use this to inspect a published or draft configuration."
      }
    },
    "/v1/agents/{agentId}/versions/{versionNumber}/functions": {
      "get": {
        "operationId": "listAgentVersionFunctions",
        "parameters": [
          {
            "name": "agentId",
            "required": true,
            "in": "path",
            "description": "ID of the agent",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "versionNumber",
            "required": true,
            "in": "path",
            "description": "Version number of the agent",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "403": {
            "description": "The agent does not exist in your workspace or does not belong to it.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "403 error",
                    "value": {
                      "statusCode": 403,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Agent not found or does not belong to your organization",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "200": {
            "description": "Successful response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "error",
                    "statusCode",
                    "message",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "statusCode": {
                      "type": "integer",
                      "example": 200
                    },
                    "message": {
                      "type": "string",
                      "example": "Success"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "description": "Function ID."
                          },
                          "agent_id": {
                            "type": "string",
                            "description": "Unprefixed agent ID (no agent_ prefix)."
                          },
                          "version_number": {
                            "type": "string",
                            "example": "1",
                            "description": "Version number. Serialized as a string (the column is a 64-bit integer)."
                          },
                          "displayName": {
                            "type": "string",
                            "nullable": true
                          },
                          "type": {
                            "type": "string",
                            "nullable": true
                          },
                          "description": {
                            "type": "string",
                            "nullable": true
                          },
                          "config": {
                            "type": "object",
                            "additionalProperties": true,
                            "nullable": true
                          },
                          "createdAt": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "updatedAt": {
                            "type": "string",
                            "format": "date-time"
                          }
                        }
                      }
                    },
                    "timestamp": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, expired, or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "401 error",
                    "value": {
                      "statusCode": 401,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Invalid API key",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "versionNumber is not a number.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "Non-numeric versionNumber",
                    "value": {
                      "statusCode": 400,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "column \"nan\" does not exist",
                      "errors": [
                        "column \"nan\" does not exist"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "summary": "List Agent Version Functions",
        "tags": [
          "Agents"
        ],
        "description": "Returns the functions configured on one version of an agent in your workspace."
      }
    },
    "/v1/agents/{agentId}/versions/{versionNumber}/functions/merged-description": {
      "get": {
        "operationId": "getAgentFunctionDescriptions",
        "parameters": [
          {
            "name": "agentId",
            "required": true,
            "in": "path",
            "description": "ID of the agent",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "versionNumber",
            "required": true,
            "in": "path",
            "description": "Version number of the agent",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "403": {
            "description": "The agent does not exist in your workspace or does not belong to it.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "403 error",
                    "value": {
                      "statusCode": 403,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Agent not found or does not belong to your organization",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "200": {
            "description": "Successful response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "error",
                    "statusCode",
                    "message",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "statusCode": {
                      "type": "integer",
                      "example": 200
                    },
                    "message": {
                      "type": "string",
                      "example": "Success"
                    },
                    "data": {
                      "type": "string",
                      "description": "end_call function descriptions joined by newline characters."
                    },
                    "timestamp": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, expired, or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "401 error",
                    "value": {
                      "statusCode": 401,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Invalid API key",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "versionNumber is not a number.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "Non-numeric versionNumber",
                    "value": {
                      "statusCode": 400,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "column \"nan\" does not exist",
                      "errors": [
                        "column \"nan\" does not exist"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "summary": "Get Agent Function Descriptions",
        "tags": [
          "Agents"
        ],
        "description": "Returns the descriptions of the version's end_call functions joined by newlines. Other function types are not included. An empty string when there are none."
      }
    },
    "/v1/voices/language-options": {
      "get": {
        "operationId": "listVoiceLanguageOptions",
        "summary": "List Voice Language Options",
        "description": "Lists languages that leave at least one compatible voice alongside all selected languages, scoped to the shared catalog and this workspace imports. Languages already in language_ids are not returned. API-key responses are a root array.",
        "tags": [
          "Voices"
        ],
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "language_ids",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Comma-separated selected language IDs. Omit for the initial list."
          },
          {
            "name": "provider",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Optional comma-separated provider filters."
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "code": {
                        "type": "string"
                      },
                      "name": {
                        "type": "string"
                      },
                      "voice_count": {
                        "type": "integer",
                        "minimum": 0
                      }
                    },
                    "required": [
                      "id",
                      "name",
                      "code",
                      "voice_count"
                    ]
                  }
                },
                "examples": {
                  "success": {
                    "value": [
                      {
                        "id": "lang_mfgsys4f62f0vb",
                        "code": "hi",
                        "name": "Hindi",
                        "voice_count": 9
                      }
                    ]
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FilteredErrorResponse"
                },
                "examples": {
                  "error": {
                    "value": {
                      "message": "API key is missing or invalid. You can generate this by logging in into dashboard"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FilteredErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "500 Internal Server Error",
                    "value": {
                      "message": "An unexpected error occurred. Please try again later."
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/agents/{agentId}/phone-numbers": {
      "get": {
        "operationId": "listAgentPhoneNumbers",
        "summary": "List Agent Phone Numbers",
        "description": "Lists the inbound and outbound phone numbers linked to an agent. Every version of the agent uses them: inbound calls run on its latest published version.",
        "tags": [
          "Agents"
        ],
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "agentId",
            "in": "path",
            "required": true,
            "schema": {
              "example": "agent_2g7Xy3tY53gRlp",
              "type": "string"
            },
            "description": "Agent ID from List Agents."
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "error": {
                      "type": "boolean"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "inbound": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string",
                                "example": "phn_abc123"
                              },
                              "phone_number": {
                                "type": "string",
                                "example": "9876543210",
                                "description": "The number without its country calling code."
                              },
                              "country_iso": {
                                "type": "string",
                                "example": "91",
                                "description": "Country calling code."
                              },
                              "nickname": {
                                "type": "string",
                                "nullable": true,
                                "description": "Label set in the dashboard."
                              },
                              "sip_trunk_enabled": {
                                "type": "boolean"
                              },
                              "linked_at": {
                                "type": "string",
                                "format": "date-time",
                                "nullable": true,
                                "description": "When the number was linked to the agent, when known."
                              }
                            },
                            "required": [
                              "id",
                              "phone_number",
                              "country_iso",
                              "nickname",
                              "sip_trunk_enabled",
                              "linked_at"
                            ]
                          }
                        },
                        "outbound": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string",
                                "example": "phn_abc123"
                              },
                              "phone_number": {
                                "type": "string",
                                "example": "9876543210",
                                "description": "The number without its country calling code."
                              },
                              "country_iso": {
                                "type": "string",
                                "example": "91",
                                "description": "Country calling code."
                              },
                              "nickname": {
                                "type": "string",
                                "nullable": true,
                                "description": "Label set in the dashboard."
                              },
                              "sip_trunk_enabled": {
                                "type": "boolean"
                              },
                              "linked_at": {
                                "type": "string",
                                "format": "date-time",
                                "nullable": true,
                                "description": "When the number was linked to the agent, when known."
                              }
                            },
                            "required": [
                              "id",
                              "phone_number",
                              "country_iso",
                              "nickname",
                              "sip_trunk_enabled",
                              "linked_at"
                            ]
                          }
                        }
                      },
                      "required": [
                        "inbound",
                        "outbound"
                      ]
                    },
                    "timestamp": {
                      "type": "string",
                      "format": "date-time"
                    }
                  },
                  "required": [
                    "success",
                    "error",
                    "statusCode",
                    "message",
                    "data",
                    "timestamp"
                  ]
                },
                "examples": {
                  "success": {
                    "value": {
                      "success": true,
                      "error": false,
                      "statusCode": 200,
                      "message": "Success",
                      "data": {
                        "inbound": [
                          {
                            "id": "phn_abc123",
                            "phone_number": "9876543210",
                            "country_iso": "91",
                            "nickname": "Support line",
                            "sip_trunk_enabled": false,
                            "linked_at": "2026-09-30T06:00:00.000Z"
                          }
                        ],
                        "outbound": [
                          {
                            "id": "phn_abc123",
                            "phone_number": "9876543210",
                            "country_iso": "91",
                            "nickname": "Support line",
                            "sip_trunk_enabled": false,
                            "linked_at": "2026-09-30T06:00:00.000Z"
                          }
                        ]
                      },
                      "timestamp": "2026-09-07T06:00:00.000Z"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "value": {
                      "statusCode": 401,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Invalid API key",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "The agent is not in this workspace.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CodedErrorResponse"
                },
                "examples": {
                  "agentNotFound": {
                    "value": {
                      "statusCode": 404,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Agent agent_2g7Xy3tY53gRlp not found in your organization.",
                      "errors": []
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "attachAgentPhoneNumber",
        "summary": "Attach Agent Phone Number",
        "description": "Links a workspace phone number to an agent for inbound or outbound calls. The agent needs a published version and can have at most 3 numbers per direction. A number serves one agent per direction. Set move to true to detach it from its current agent and attach it here in one transaction; live calls, unfinished outbound batches, and active outbound workflows can block the move.",
        "tags": [
          "Agents"
        ],
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "agentId",
            "in": "path",
            "required": true,
            "schema": {
              "example": "agent_2g7Xy3tY53gRlp",
              "type": "string"
            },
            "description": "Agent ID from List Agents."
          }
        ],
        "responses": {
          "201": {
            "description": "Successful response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "error": {
                      "type": "boolean"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string",
                          "description": "Link record ID."
                        },
                        "agent_id": {
                          "type": "string",
                          "example": "agent_2g7Xy3tY53gRlp"
                        },
                        "phone_number_id": {
                          "type": "string",
                          "example": "phn_abc123"
                        },
                        "direction": {
                          "type": "string",
                          "enum": [
                            "inbound",
                            "outbound"
                          ],
                          "description": "inbound: the number rings this agent. outbound: the agent calls from it."
                        },
                        "linked_at": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "linked_by": {
                          "type": "string",
                          "nullable": true,
                          "description": "User who created the link, when known."
                        },
                        "unlinked_at": {
                          "type": "string",
                          "format": "date-time",
                          "nullable": true,
                          "description": "Null while the link is current."
                        },
                        "unlinked_by": {
                          "type": "string",
                          "nullable": true,
                          "description": "User who ended the link, when known."
                        },
                        "unlink_reason": {
                          "type": "string",
                          "nullable": true,
                          "enum": [
                            "manual",
                            "agent_deleted",
                            "number_deleted",
                            "number_released"
                          ],
                          "description": "Why the link ended: manual (detached), agent_deleted, number_deleted, or number_released (the rental expired or the number was withdrawn). Null while the link is current."
                        }
                      },
                      "required": [
                        "id",
                        "agent_id",
                        "phone_number_id",
                        "direction",
                        "linked_at",
                        "unlinked_at",
                        "unlink_reason"
                      ]
                    },
                    "timestamp": {
                      "type": "string",
                      "format": "date-time"
                    }
                  },
                  "required": [
                    "success",
                    "error",
                    "statusCode",
                    "message",
                    "data",
                    "timestamp"
                  ]
                },
                "examples": {
                  "success": {
                    "value": {
                      "success": true,
                      "error": false,
                      "statusCode": 201,
                      "message": "Success",
                      "data": {
                        "id": "k2m9q4wz1abcde",
                        "direction": "outbound",
                        "linked_at": "2026-09-30T06:00:00.000Z",
                        "linked_by": null,
                        "unlinked_at": null,
                        "unlinked_by": null,
                        "unlink_reason": null,
                        "agent_id": "agent_2g7Xy3tY53gRlp",
                        "phone_number_id": "phn_abc123"
                      },
                      "timestamp": "2026-09-07T06:00:00.000Z"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "value": {
                      "statusCode": 401,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Invalid API key",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "The agent has no published version, already has 3 numbers in this direction, or the body is invalid. A SIP trunk number is also refused for a Conversational Flow agent whose published version has a call transfer node.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CodedErrorResponse"
                },
                "examples": {
                  "agentNotPublished": {
                    "value": {
                      "statusCode": 400,
                      "error": true,
                      "success": false,
                      "data": {
                        "code": "AGENT_NOT_PUBLISHED"
                      },
                      "message": "Publish the agent before attaching a phone number.",
                      "errors": []
                    }
                  },
                  "limitReached": {
                    "value": {
                      "statusCode": 400,
                      "error": true,
                      "success": false,
                      "data": {
                        "code": "PHONE_NUMBER_LIMIT_REACHED",
                        "limit": 3
                      },
                      "message": "An agent can have at most 3 outbound numbers.",
                      "errors": []
                    }
                  },
                  "sipTrunkWithCallTransfer": {
                    "value": {
                      "statusCode": 400,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "SIP trunk numbers cannot be used for conversational flow agents that include a call transfer node.",
                      "errors": [
                        "SIP trunk numbers cannot be used for conversational flow agents that include a call transfer node."
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "DialNexa's shared default number cannot answer inbound calls.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CodedErrorResponse"
                },
                "examples": {
                  "defaultNumberInbound": {
                    "value": {
                      "statusCode": 403,
                      "error": true,
                      "success": false,
                      "data": {
                        "code": "DEFAULT_NUMBER_NOT_ALLOWED_INBOUND"
                      },
                      "message": "A default number cannot be used for inbound calls.",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "The agent or the phone number is not in this workspace.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CodedErrorResponse"
                },
                "examples": {
                  "agentNotFound": {
                    "value": {
                      "statusCode": 404,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Agent agent_2g7Xy3tY53gRlp not found in your organization.",
                      "errors": []
                    }
                  },
                  "phoneNumberNotFound": {
                    "value": {
                      "statusCode": 404,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Phone number phn_abc123 not found in your organization.",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "The number is already linked, or moving it is blocked by calls, outbound batches, or outbound workflows.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CodedErrorResponse"
                },
                "examples": {
                  "alreadyLinked": {
                    "value": {
                      "statusCode": 409,
                      "error": true,
                      "success": false,
                      "data": {
                        "code": "PHONE_NUMBER_ALREADY_LINKED"
                      },
                      "message": "This number is already linked to this agent for outbound calls.",
                      "errors": []
                    }
                  },
                  "linkedToOtherAgent": {
                    "value": {
                      "statusCode": 409,
                      "error": true,
                      "success": false,
                      "data": {
                        "code": "PHONE_NUMBER_LINKED_TO_OTHER_AGENT",
                        "agent_id": "agent_7h2Kq9Lm4Np3Rs",
                        "agent_title": "Collections"
                      },
                      "message": "This number is linked to Collections for outbound calls. Detach it there first, or send move: true to move it to this agent.",
                      "errors": []
                    }
                  },
                  "usedByBatch": {
                    "value": {
                      "statusCode": 409,
                      "error": true,
                      "success": false,
                      "data": {
                        "code": "NUMBER_USED_BY_BATCH",
                        "batches": [
                          {
                            "id": "batch_abc123",
                            "title": "September renewals",
                            "status": "paused"
                          }
                        ],
                        "live_calls": 0
                      },
                      "message": "1 unfinished batch(es) (\"September renewals\") and 0 live call(s) use this number. Change the batches' number or cancel them first.",
                      "errors": []
                    }
                  },
                  "liveCalls": {
                    "value": {
                      "statusCode": 409,
                      "error": true,
                      "success": false,
                      "data": {
                        "code": "PHONE_NUMBER_HAS_LIVE_CALLS",
                        "live_calls": 2,
                        "batches": []
                      },
                      "message": "2 call(s) are in progress on this number. Wait for them to finish, then retry.",
                      "errors": []
                    }
                  },
                  "activeWorkflows": {
                    "value": {
                      "statusCode": 409,
                      "error": true,
                      "success": false,
                      "data": {
                        "code": "PHONE_NUMBER_USED_IN_ACTIVE_WORKFLOWS",
                        "affected_workflows": [
                          {
                            "id": "Xy7Kp2mQ9rT4vB",
                            "title": "Lead follow-up",
                            "status": "active"
                          }
                        ]
                      },
                      "message": "This phone number is used in 1 active workflow(s). Pause those workflows first, then retry.",
                      "errors": []
                    }
                  }
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LinkAgentPhoneNumberRequest"
              },
              "examples": {
                "request": {
                  "value": {
                    "phone_number_id": "phn_abc123",
                    "direction": "outbound"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/agents/{agentId}/phone-numbers/history": {
      "get": {
        "operationId": "getAgentPhoneNumberHistory",
        "summary": "Get Agent Phone Number History",
        "description": "Returns every link between the agent and a phone number, newest first, with when each link started and ended and why it ended.",
        "tags": [
          "Agents"
        ],
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "agentId",
            "in": "path",
            "required": true,
            "schema": {
              "example": "agent_2g7Xy3tY53gRlp",
              "type": "string"
            },
            "description": "Agent ID from List Agents."
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "error": {
                      "type": "boolean"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "description": "Link record ID."
                          },
                          "agent_id": {
                            "type": "string",
                            "example": "agent_2g7Xy3tY53gRlp"
                          },
                          "phone_number_id": {
                            "type": "string",
                            "example": "phn_abc123"
                          },
                          "direction": {
                            "type": "string",
                            "enum": [
                              "inbound",
                              "outbound"
                            ],
                            "description": "inbound: the number rings this agent. outbound: the agent calls from it."
                          },
                          "linked_at": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "linked_by": {
                            "type": "string",
                            "nullable": true,
                            "description": "User who created the link, when known."
                          },
                          "unlinked_at": {
                            "type": "string",
                            "format": "date-time",
                            "nullable": true,
                            "description": "Null while the link is current."
                          },
                          "unlinked_by": {
                            "type": "string",
                            "nullable": true,
                            "description": "User who ended the link, when known."
                          },
                          "unlink_reason": {
                            "type": "string",
                            "nullable": true,
                            "enum": [
                              "manual",
                              "agent_deleted",
                              "number_deleted",
                              "number_released"
                            ],
                            "description": "Why the link ended: manual (detached), agent_deleted, number_deleted, or number_released (the rental expired or the number was withdrawn). Null while the link is current."
                          },
                          "phone_number": {
                            "type": "string",
                            "nullable": true,
                            "example": "9876543210",
                            "description": "The number without its country calling code."
                          },
                          "country_iso": {
                            "type": "string",
                            "nullable": true,
                            "example": "91"
                          }
                        },
                        "required": [
                          "id",
                          "agent_id",
                          "phone_number_id",
                          "direction",
                          "linked_at",
                          "unlinked_at",
                          "unlink_reason"
                        ]
                      }
                    },
                    "timestamp": {
                      "type": "string",
                      "format": "date-time"
                    }
                  },
                  "required": [
                    "success",
                    "error",
                    "statusCode",
                    "message",
                    "data",
                    "timestamp"
                  ]
                },
                "examples": {
                  "success": {
                    "value": {
                      "success": true,
                      "error": false,
                      "statusCode": 200,
                      "message": "Success",
                      "data": [
                        {
                          "id": "k2m9q4wz1abcde",
                          "direction": "inbound",
                          "linked_at": "2026-09-30T06:00:00.000Z",
                          "linked_by": null,
                          "unlinked_at": "2026-09-30T08:00:00.000Z",
                          "unlinked_by": null,
                          "unlink_reason": "manual",
                          "agent_id": "agent_2g7Xy3tY53gRlp",
                          "phone_number_id": "phn_abc123",
                          "phone_number": "9876543210",
                          "country_iso": "91"
                        }
                      ],
                      "timestamp": "2026-09-07T06:00:00.000Z"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "value": {
                      "statusCode": 401,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Invalid API key",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "The agent is not in this workspace.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CodedErrorResponse"
                },
                "examples": {
                  "agentNotFound": {
                    "value": {
                      "statusCode": 404,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Agent agent_2g7Xy3tY53gRlp not found in your organization.",
                      "errors": []
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/agents/{agentId}/phone-numbers/{phoneNumberId}": {
      "delete": {
        "operationId": "detachAgentPhoneNumber",
        "summary": "Detach Agent Phone Number",
        "description": "Unlinks a phone number from an agent for one direction. Live calls block either direction. Unfinished batches and active workflows using the number additionally block outbound detachment.",
        "tags": [
          "Agents"
        ],
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "agentId",
            "in": "path",
            "required": true,
            "schema": {
              "example": "agent_2g7Xy3tY53gRlp",
              "type": "string"
            },
            "description": "Agent ID from List Agents."
          },
          {
            "name": "phoneNumberId",
            "in": "path",
            "required": true,
            "schema": {
              "example": "phn_2g7Xy3tY53gRlp",
              "type": "string"
            },
            "description": "Phone number ID from List Agent Phone Numbers."
          },
          {
            "name": "direction",
            "required": true,
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "inbound",
                "outbound"
              ]
            },
            "description": "The direction to detach. A number linked for both directions keeps the other one."
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "error": {
                      "type": "boolean"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string",
                          "description": "Link record ID."
                        },
                        "agent_id": {
                          "type": "string",
                          "example": "agent_2g7Xy3tY53gRlp"
                        },
                        "phone_number_id": {
                          "type": "string",
                          "example": "phn_abc123"
                        },
                        "direction": {
                          "type": "string",
                          "enum": [
                            "inbound",
                            "outbound"
                          ],
                          "description": "inbound: the number rings this agent. outbound: the agent calls from it."
                        },
                        "linked_at": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "linked_by": {
                          "type": "string",
                          "nullable": true,
                          "description": "User who created the link, when known."
                        },
                        "unlinked_at": {
                          "type": "string",
                          "format": "date-time",
                          "nullable": true,
                          "description": "Null while the link is current."
                        },
                        "unlinked_by": {
                          "type": "string",
                          "nullable": true,
                          "description": "User who ended the link, when known."
                        },
                        "unlink_reason": {
                          "type": "string",
                          "nullable": true,
                          "enum": [
                            "manual",
                            "agent_deleted",
                            "number_deleted",
                            "number_released"
                          ],
                          "description": "Why the link ended: manual (detached), agent_deleted, number_deleted, or number_released (the rental expired or the number was withdrawn). Null while the link is current."
                        }
                      },
                      "required": [
                        "id",
                        "agent_id",
                        "phone_number_id",
                        "direction",
                        "linked_at",
                        "unlinked_at",
                        "unlink_reason"
                      ],
                      "nullable": true
                    },
                    "timestamp": {
                      "type": "string",
                      "format": "date-time"
                    }
                  },
                  "required": [
                    "success",
                    "error",
                    "statusCode",
                    "message",
                    "data",
                    "timestamp"
                  ]
                },
                "examples": {
                  "success": {
                    "value": {
                      "success": true,
                      "error": false,
                      "statusCode": 200,
                      "message": "Success",
                      "data": {
                        "id": "k2m9q4wz1abcde",
                        "direction": "outbound",
                        "linked_at": "2026-09-30T06:00:00.000Z",
                        "linked_by": null,
                        "unlinked_at": "2026-09-30T08:00:00.000Z",
                        "unlinked_by": null,
                        "unlink_reason": "manual",
                        "agent_id": "agent_2g7Xy3tY53gRlp",
                        "phone_number_id": "phn_abc123"
                      },
                      "timestamp": "2026-09-07T06:00:00.000Z"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "error": {
                    "value": {
                      "statusCode": 401,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "Invalid API key",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "direction is missing or is not inbound or outbound.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CodedErrorResponse"
                },
                "examples": {
                  "invalidDirection": {
                    "value": {
                      "statusCode": 400,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "direction must be one of the following values: inbound, outbound",
                      "errors": [
                        "direction must be one of the following values: inbound, outbound"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "The agent or number is not in this workspace, or the number is not linked to this agent in that direction.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CodedErrorResponse"
                },
                "examples": {
                  "notLinked": {
                    "value": {
                      "statusCode": 404,
                      "error": true,
                      "success": false,
                      "data": [],
                      "message": "This number is not linked to this agent for outbound calls.",
                      "errors": []
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "The number is still in use. Resolve what data lists, then retry.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CodedErrorResponse"
                },
                "examples": {
                  "usedByBatch": {
                    "value": {
                      "statusCode": 409,
                      "error": true,
                      "success": false,
                      "data": {
                        "code": "NUMBER_USED_BY_BATCH",
                        "batches": [
                          {
                            "id": "batch_abc123",
                            "title": "September renewals",
                            "status": "paused"
                          }
                        ],
                        "live_calls": 0
                      },
                      "message": "1 unfinished batch(es) (\"September renewals\") and 0 live call(s) use this number. Change the batches' number or cancel them first.",
                      "errors": []
                    }
                  },
                  "liveCalls": {
                    "value": {
                      "statusCode": 409,
                      "error": true,
                      "success": false,
                      "data": {
                        "code": "PHONE_NUMBER_HAS_LIVE_CALLS",
                        "live_calls": 2,
                        "batches": []
                      },
                      "message": "2 call(s) are in progress on this number. Wait for them to finish, then retry.",
                      "errors": []
                    }
                  },
                  "activeWorkflows": {
                    "value": {
                      "statusCode": 409,
                      "error": true,
                      "success": false,
                      "data": {
                        "code": "PHONE_NUMBER_USED_IN_ACTIVE_WORKFLOWS",
                        "affected_workflows": [
                          {
                            "id": "Xy7Kp2mQ9rT4vB",
                            "title": "Lead follow-up",
                            "status": "active"
                          }
                        ]
                      },
                      "message": "This phone number is used in 1 active workflow(s). Pause those workflows first, then retry.",
                      "errors": []
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/batch-calls/{id}/phone-number": {
      "patch": {
        "operationId": "changeBatchCallPhoneNumber",
        "summary": "Change Batch Call Phone Number",
        "description": "Changes the From number for a draft, scheduled, or paused batch to another outbound number linked to its agent. Pause running or waiting batches first and wait for in-progress calls to finish. Undialed calls and parked retries use the new number; placed calls keep their original number. The agent version and batch status stay the same.",
        "tags": [
          "Batch Calls"
        ],
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "batch_abc123"
            },
            "description": "Batch ID from List Batch Calls."
          }
        ],
        "responses": {
          "200": {
            "description": "The number was changed. API-key callers receive an empty object because the response projection omits the control result.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {}
                },
                "examples": {
                  "success": {
                    "value": {}
                  }
                }
              }
            }
          },
          "400": {
            "description": "PHONE_NUMBER_NOT_LINKED: choose an outbound number of this agent. BATCH_TERMINAL: a batch whose status is completed, cancelled or deleted cannot change numbers. Invalid request bodies also return 400.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FilteredErrorResponse"
                },
                "examples": {
                  "error": {
                    "value": {
                      "message": "Request validation failed: phone_number_id must be a string"
                    }
                  },
                  "batchTerminal": {
                    "summary": "400 Bad Request",
                    "value": {
                      "message": "Request validation failed: Batch \"Q3 Follow-up Batch\" is completed; its number can no longer change.",
                      "data": {
                        "code": "BATCH_TERMINAL"
                      }
                    }
                  },
                  "phoneNumberNotLinked": {
                    "summary": "400 Bad Request",
                    "value": {
                      "message": "Request validation failed: Phone number phn_2g7Xy3tY53gRlp is not an outbound number of agent agent_mgao6051Rk718Y.",
                      "data": {
                        "code": "PHONE_NUMBER_NOT_LINKED"
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Batch not found in this workspace, including a batch that has been removed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FilteredErrorResponse"
                },
                "examples": {
                  "error": {
                    "value": {
                      "message": "Campaign with ID 2g7Xy3tY53gRlp not found"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "BATCH_NOT_PAUSED: pause the batch first. BATCH_HAS_LIVE_CALLS: wait until its in-progress calls finish.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FilteredErrorResponse"
                },
                "examples": {
                  "error": {
                    "value": {
                      "message": "Pause the batch before changing its phone number.",
                      "data": {
                        "code": "BATCH_NOT_PAUSED"
                      }
                    }
                  },
                  "batchHasLiveCalls": {
                    "summary": "409 Conflict",
                    "value": {
                      "message": "2 call(s) from this batch are still in progress. Wait for them to finish, then retry.",
                      "data": {
                        "code": "BATCH_HAS_LIVE_CALLS",
                        "live_calls": 2
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "The API key is missing or invalid.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FilteredErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "Invalid key",
                    "value": {
                      "message": "API key is missing or invalid. You can generate this by logging in into dashboard"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "The request could not be completed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FilteredErrorResponse"
                },
                "examples": {
                  "error": {
                    "summary": "Server error",
                    "value": {
                      "message": "An unexpected error occurred. Please try again later."
                    }
                  }
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "phone_number_id": {
                    "type": "string",
                    "description": "One of the batch agent's outbound phone number IDs.",
                    "example": "phn_abc123"
                  }
                },
                "required": [
                  "phone_number_id"
                ]
              },
              "examples": {
                "request": {
                  "value": {
                    "phone_number_id": "phn_abc123"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/agents/{id}/tests": {
      "get": {
        "operationId": "listAgentEvalTests",
        "summary": "List Agent Evaluation Tests",
        "description": "Lists saved tests for an agent, grouped by folder and oldest creation first within each folder. Includes enabled state and the latest completed-run result.",
        "tags": [
          "Agent Evaluations"
        ],
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Agent ID from List Agents."
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "error",
                    "statusCode",
                    "message",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "statusCode": {
                      "type": "integer",
                      "example": 200
                    },
                    "message": {
                      "type": "string",
                      "example": "Success"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/AgentEvalTest"
                      }
                    },
                    "timestamp": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, expired or invalid API key."
          },
          "404": {
            "description": "Agent, test, run or conversation was not found in this workspace."
          }
        }
      },
      "post": {
        "operationId": "createAgentEvalTest",
        "summary": "Create Agent Evaluation Test",
        "description": "Saves a test definition without starting a run or changing the agent version. Repeating the request creates another test.",
        "tags": [
          "Agent Evaluations"
        ],
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Agent ID from List Agents."
          }
        ],
        "responses": {
          "201": {
            "description": "Successful response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "error",
                    "statusCode",
                    "message",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "statusCode": {
                      "type": "integer",
                      "example": 201
                    },
                    "message": {
                      "type": "string",
                      "example": "Success"
                    },
                    "data": {
                      "$ref": "#/components/schemas/AgentEvalTest"
                    },
                    "timestamp": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, expired or invalid API key."
          },
          "404": {
            "description": "Agent, test, run or conversation was not found in this workspace."
          },
          "400": {
            "description": "Invalid test definition or run selection. For runs, check test ownership, enabled tests, target version and secondary-model availability."
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SaveAgentEvalTest"
              },
              "examples": {
                "request": {
                  "value": {
                    "name": "Answers a pricing question",
                    "type": "simulation",
                    "config": {
                      "scenario": "Ask what the product costs.",
                      "criteria": [
                        "Uses the pricing in the agent prompt."
                      ],
                      "mock_strategy": "all",
                      "mock_fallback": "error"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/agents/{id}/tests/{testId}": {
      "patch": {
        "operationId": "updateAgentEvalTest",
        "summary": "Update Agent Evaluation Test",
        "description": "Replaces the saved name, folder, type and configuration of a test. Supply all required fields; omitting folder clears it. Does not start a run.",
        "tags": [
          "Agent Evaluations"
        ],
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Agent ID from List Agents."
          },
          {
            "name": "testId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Saved test ID from List Agent Evaluation Tests."
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "error",
                    "statusCode",
                    "message",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "statusCode": {
                      "type": "integer",
                      "example": 200
                    },
                    "message": {
                      "type": "string",
                      "example": "Success"
                    },
                    "data": {
                      "$ref": "#/components/schemas/AgentEvalTest"
                    },
                    "timestamp": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, expired or invalid API key."
          },
          "404": {
            "description": "Agent, test, run or conversation was not found in this workspace."
          },
          "400": {
            "description": "Invalid test definition or run selection. For runs, check test ownership, enabled tests, target version and secondary-model availability."
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SaveAgentEvalTest"
              },
              "examples": {
                "request": {
                  "value": {
                    "name": "Answers a pricing question",
                    "type": "simulation",
                    "config": {
                      "scenario": "Ask what the product costs.",
                      "criteria": [
                        "Uses the pricing in the agent prompt."
                      ],
                      "mock_strategy": "all",
                      "mock_fallback": "error"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteAgentEvalTest",
        "summary": "Delete Agent Evaluation Test",
        "description": "Removes a non-Core test from the saved list. Core tests cannot be deleted. Verify deletion with List Agent Evaluation Tests.",
        "tags": [
          "Agent Evaluations"
        ],
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Agent ID from List Agents."
          },
          {
            "name": "testId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Saved test ID from List Agent Evaluation Tests."
          }
        ],
        "responses": {
          "204": {
            "description": "Test removed. No response body."
          },
          "401": {
            "description": "Missing, expired or invalid API key."
          },
          "404": {
            "description": "Agent, test, run or conversation was not found in this workspace."
          },
          "400": {
            "description": "Core tests can be switched off, not deleted."
          }
        }
      }
    },
    "/v1/agents/{id}/test-runs": {
      "get": {
        "operationId": "listAgentEvalRuns",
        "summary": "List Agent Evaluation Runs",
        "description": "Returns up to the 100 newest evaluation runs for this agent, including progress counters and insights status.",
        "tags": [
          "Agent Evaluations"
        ],
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Agent ID from List Agents."
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "error",
                    "statusCode",
                    "message",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "statusCode": {
                      "type": "integer",
                      "example": 200
                    },
                    "message": {
                      "type": "string",
                      "example": "Success"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/AgentEvalRun"
                      }
                    },
                    "timestamp": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, expired or invalid API key."
          },
          "404": {
            "description": "Agent, test, run or conversation was not found in this workspace."
          }
        }
      },
      "post": {
        "operationId": "startAgentEvalRun",
        "summary": "Start Agent Evaluation Run",
        "description": "Queues test conversations for the selected saved agent version. Evaluation test calls are not charged to the workspace wallet; real tool execution can still cause external actions. Poll Get Agent Evaluation Run for completion; retrying after a completed run creates a new run.",
        "tags": [
          "Agent Evaluations"
        ],
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Agent ID from List Agents."
          }
        ],
        "responses": {
          "201": {
            "description": "Successful response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "error",
                    "statusCode",
                    "message",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "statusCode": {
                      "type": "integer",
                      "example": 201
                    },
                    "message": {
                      "type": "string",
                      "example": "Success"
                    },
                    "data": {
                      "$ref": "#/components/schemas/AgentEvalRun"
                    },
                    "timestamp": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, expired or invalid API key."
          },
          "404": {
            "description": "Agent, test, run or conversation was not found in this workspace."
          },
          "400": {
            "description": "Invalid test definition or run selection. For runs, check test ownership, enabled tests, target version and secondary-model availability."
          },
          "409": {
            "description": "A run is already in progress for this agent. Poll it before starting another."
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StartAgentEvalRun"
              },
              "examples": {
                "request": {
                  "value": {
                    "test_ids": [
                      "k7x2m9q4wz1abc"
                    ],
                    "repeat": 1,
                    "target": "draft"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/agents/{id}/test-runs/{runId}": {
      "get": {
        "operationId": "getAgentEvalRun",
        "summary": "Get Agent Evaluation Run",
        "description": "Returns run progress, outcomes and conversation IDs. queued and running are non-final; completed and cancelled are terminal. Completion does not mean every test passed.",
        "tags": [
          "Agent Evaluations"
        ],
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Agent ID from List Agents."
          },
          {
            "name": "runId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Run ID from Start or List Agent Evaluation Runs."
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "error",
                    "statusCode",
                    "message",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "statusCode": {
                      "type": "integer",
                      "example": 200
                    },
                    "message": {
                      "type": "string",
                      "example": "Success"
                    },
                    "data": {
                      "$ref": "#/components/schemas/AgentEvalRunDetail"
                    },
                    "timestamp": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, expired or invalid API key."
          },
          "404": {
            "description": "Agent, test, run or conversation was not found in this workspace."
          }
        }
      }
    },
    "/v1/agents/{id}/test-runs/{runId}/conversations/{conversationId}": {
      "get": {
        "operationId": "getAgentEvalConversation",
        "summary": "Get Agent Evaluation Conversation",
        "description": "Returns one test conversation with its transcript, judgement, extracted fields and available recording and latency data. An unfinished conversation may have empty judgement arrays and no outcome.",
        "tags": [
          "Agent Evaluations"
        ],
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Agent ID from List Agents."
          },
          {
            "name": "runId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Run ID from Start or List Agent Evaluation Runs."
          },
          {
            "name": "conversationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Conversation ID from Get Agent Evaluation Run."
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "error",
                    "statusCode",
                    "message",
                    "data",
                    "timestamp"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "error": {
                      "type": "boolean",
                      "enum": [
                        false
                      ]
                    },
                    "statusCode": {
                      "type": "integer",
                      "example": 200
                    },
                    "message": {
                      "type": "string",
                      "example": "Success"
                    },
                    "data": {
                      "$ref": "#/components/schemas/AgentEvalConversation"
                    },
                    "timestamp": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, expired or invalid API key."
          },
          "404": {
            "description": "Agent, test, run or conversation was not found in this workspace."
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearer": {
        "scheme": "bearer",
        "type": "http"
      }
    },
    "schemas": {
      "Agents": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "agent_2g7Xy3tY53gRlp",
            "description": "Signed agent ID"
          },
          "folder_id": {
            "type": "string",
            "nullable": true
          },
          "current_version_number": {
            "type": "string",
            "example": "3",
            "description": "Number of the current version. Serialized as a string (the column is a 64-bit integer)."
          },
          "timezone": {
            "type": "string",
            "nullable": true
          },
          "agent_type": {
            "type": "string",
            "enum": [
              "Single_Prompt_Agent",
              "Conversational_Flow_Agent",
              "IVR_Agent"
            ]
          },
          "pipeline_type": {
            "type": "string",
            "enum": [
              "Cascaded",
              "Speech_To_Speech"
            ],
            "nullable": true
          },
          "webhook_id": {
            "type": "string",
            "nullable": true
          },
          "current_version": {
            "type": "object",
            "nullable": true,
            "description": "The version current_version_number points to.",
            "properties": {
              "agent_id": {
                "type": "string"
              },
              "version_number": {
                "type": "string",
                "example": "1",
                "description": "Version number. Serialized as a string (the column is a 64-bit integer)."
              },
              "version_title": {
                "type": "string",
                "nullable": true
              },
              "title": {
                "type": "string",
                "nullable": true
              },
              "description": {
                "type": "string",
                "nullable": true
              },
              "llm_id": {
                "type": "string",
                "nullable": true
              },
              "language_id": {
                "type": "string"
              },
              "voice_id": {
                "type": "string"
              },
              "voice_model_id": {
                "type": "string",
                "nullable": true
              },
              "voice_speed": {
                "type": "number",
                "nullable": true
              },
              "voice_temperature": {
                "type": "number",
                "nullable": true
              },
              "voice_volume": {
                "type": "number",
                "nullable": true
              },
              "voice_pitch": {
                "type": "number",
                "nullable": true
              },
              "prompt_text": {
                "type": "string"
              },
              "system_prompt_text": {
                "type": "string",
                "nullable": true
              },
              "conversation_start_type": {
                "type": "string"
              },
              "welcome_message": {
                "type": "string",
                "nullable": true
              },
              "knowledge_base_ids": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "nullable": true
              },
              "kb_max_chunks": {
                "type": "number",
                "nullable": true
              },
              "kb_min_score": {
                "type": "number",
                "nullable": true
              },
              "is_published": {
                "type": "boolean"
              },
              "voicemail_detection": {
                "type": "boolean",
                "nullable": true
              },
              "hangup_on_voicemail": {
                "type": "boolean",
                "nullable": true
              },
              "voicemail_message": {
                "type": "string",
                "nullable": true
              },
              "end_call_on_silence_sec": {
                "type": "number"
              },
              "max_call_duration_sec": {
                "type": "number"
              },
              "ring_duration_sec": {
                "type": "number"
              },
              "background_sound": {
                "type": "string",
                "nullable": true
              },
              "ambient_noise": {
                "type": "boolean"
              },
              "background_sound_volume": {
                "type": "number"
              },
              "llm_temperature": {
                "type": "number"
              },
              "fallback_llm_enabled": {
                "type": "boolean",
                "nullable": true
              },
              "llm_fallback_delay_ms": {
                "type": "number",
                "nullable": true
              },
              "llm_fallback_model": {
                "type": "string",
                "nullable": true
              },
              "fallback_stt_enabled": {
                "type": "boolean",
                "nullable": true
              },
              "stt_fallback_wait_ms": {
                "type": "number",
                "nullable": true
              },
              "stt_fallback_transcriber_id": {
                "type": "string",
                "nullable": true
              },
              "predictive_preprocessing_enabled": {
                "type": "boolean",
                "nullable": true
              },
              "prompt_caching_enabled": {
                "type": "boolean",
                "nullable": true
              },
              "responsiveness": {
                "type": "number"
              },
              "interruption_sensitivity": {
                "type": "number"
              },
              "response_eagerness": {
                "type": "number"
              },
              "transcriber_id": {
                "type": "string",
                "nullable": true
              },
              "denoising_mode": {
                "type": "string",
                "nullable": true
              },
              "denoise_strength": {
                "type": "number",
                "nullable": true
              },
              "boosted_keywords": {
                "type": "string",
                "nullable": true
              },
              "boost_dynamic_variables": {
                "type": "boolean",
                "nullable": true
              },
              "reminder_message_interval": {
                "type": "number",
                "nullable": true
              },
              "reminder_message_content": {
                "type": "string",
                "nullable": true
              },
              "default_dynamic_variables": {
                "nullable": true
              },
              "call_transfer_settings": {
                "nullable": true
              },
              "agent_identity": {
                "type": "string",
                "nullable": true
              },
              "agent_background": {
                "type": "string",
                "nullable": true
              },
              "node_positions": {
                "type": "string",
                "nullable": true
              },
              "ivr_menu": {
                "type": "object",
                "additionalProperties": true,
                "nullable": true
              },
              "audio_cache_enabled": {
                "type": "boolean",
                "nullable": true
              },
              "language": {
                "type": "object",
                "nullable": true,
                "additionalProperties": true,
                "description": "Associated resource when configured. Included record; its own IDs are unprefixed."
              },
              "voice": {
                "type": "object",
                "nullable": true,
                "additionalProperties": true,
                "description": "Associated resource when configured. Included record; its own IDs are unprefixed."
              },
              "llm": {
                "type": "object",
                "nullable": true,
                "additionalProperties": true,
                "description": "Associated resource when configured. Included record; its own IDs are unprefixed."
              },
              "createdAt": {
                "type": "string",
                "format": "date-time"
              },
              "updatedAt": {
                "type": "string",
                "format": "date-time"
              },
              "end_call_on_hold_sec": {
                "type": "integer",
                "nullable": true,
                "description": "Seconds to wait in a confirmed hold before hanging up; null when disabled."
              },
              "language_default_message": {
                "type": "string",
                "nullable": true,
                "description": "Message spoken when the caller language is not supported."
              },
              "prompt_tokens": {
                "type": "integer",
                "nullable": true,
                "description": "Token count of the stored prompt, when computed."
              },
              "secondary_language_ids": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "Additional language IDs the version can switch to."
              },
              "speech_to_speech_english_accent": {
                "type": "string",
                "enum": [
                  "indian",
                  "british",
                  "american"
                ],
                "description": "Accent of the agent's English on Speech-to-Speech calls: indian (default), british or american."
              },
              "pronunciations": {
                "type": "array",
                "description": "Pronunciation overrides for this version.",
                "items": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "agent_id": {
                      "type": "string",
                      "description": "Unprefixed agent ID."
                    },
                    "version_number": {
                      "type": "string"
                    },
                    "original_word": {
                      "type": "string"
                    },
                    "pronunciation_format": {
                      "type": "string"
                    },
                    "phonetic_pronunciation": {
                      "type": "string",
                      "nullable": true
                    },
                    "is_deleted": {
                      "type": "boolean"
                    },
                    "createdAt": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "updatedAt": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                }
              },
              "postcall_analysis": {
                "type": "array",
                "description": "Post-call fields of this version. llm_id is the extraction LLM (null for the workspace default).",
                "items": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "field_name": {
                      "type": "string"
                    },
                    "field_description": {
                      "type": "string",
                      "nullable": true
                    },
                    "field_type": {
                      "type": "string",
                      "enum": [
                        "TEXT",
                        "SELECTOR",
                        "BOOLEAN",
                        "NUMBER",
                        "DATETIME"
                      ]
                    },
                    "agent_version_number": {
                      "type": "string"
                    },
                    "additional_fields": {
                      "nullable": true
                    },
                    "display_order": {
                      "type": "integer",
                      "nullable": true
                    },
                    "llm_id": {
                      "type": "string",
                      "nullable": true,
                      "example": "llm_A1B2C3D4E5F6G7"
                    }
                  }
                }
              },
              "agent_functions": {
                "type": "array",
                "description": "Functions of this version. Returned by Get Agent, create and update; not by List Agents. agent_id is unprefixed.",
                "items": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "agent_id": {
                      "type": "string"
                    },
                    "version_number": {
                      "type": "string"
                    },
                    "display_name": {
                      "type": "string",
                      "nullable": true
                    },
                    "type": {
                      "type": "string"
                    },
                    "description": {
                      "type": "string",
                      "nullable": true
                    },
                    "config": {
                      "type": "object",
                      "additionalProperties": true,
                      "nullable": true
                    }
                  }
                }
              }
            }
          },
          "versions": {
            "type": "array",
            "description": "Every version, newest first.",
            "items": {
              "type": "object",
              "properties": {
                "agent_id": {
                  "type": "string"
                },
                "version_number": {
                  "type": "string",
                  "example": "1",
                  "description": "Version number. Serialized as a string (the column is a 64-bit integer)."
                },
                "version_title": {
                  "type": "string",
                  "nullable": true
                },
                "title": {
                  "type": "string",
                  "nullable": true
                },
                "description": {
                  "type": "string",
                  "nullable": true
                },
                "llm_id": {
                  "type": "string",
                  "nullable": true
                },
                "language_id": {
                  "type": "string"
                },
                "voice_id": {
                  "type": "string"
                },
                "voice_model_id": {
                  "type": "string",
                  "nullable": true
                },
                "voice_speed": {
                  "type": "number",
                  "nullable": true
                },
                "voice_temperature": {
                  "type": "number",
                  "nullable": true
                },
                "voice_volume": {
                  "type": "number",
                  "nullable": true
                },
                "voice_pitch": {
                  "type": "number",
                  "nullable": true
                },
                "prompt_text": {
                  "type": "string"
                },
                "system_prompt_text": {
                  "type": "string",
                  "nullable": true
                },
                "conversation_start_type": {
                  "type": "string"
                },
                "welcome_message": {
                  "type": "string",
                  "nullable": true
                },
                "knowledge_base_ids": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  },
                  "nullable": true
                },
                "kb_max_chunks": {
                  "type": "number",
                  "nullable": true
                },
                "kb_min_score": {
                  "type": "number",
                  "nullable": true
                },
                "is_published": {
                  "type": "boolean"
                },
                "voicemail_detection": {
                  "type": "boolean",
                  "nullable": true
                },
                "hangup_on_voicemail": {
                  "type": "boolean",
                  "nullable": true
                },
                "voicemail_message": {
                  "type": "string",
                  "nullable": true
                },
                "end_call_on_silence_sec": {
                  "type": "number"
                },
                "max_call_duration_sec": {
                  "type": "number"
                },
                "ring_duration_sec": {
                  "type": "number"
                },
                "background_sound": {
                  "type": "string",
                  "nullable": true
                },
                "ambient_noise": {
                  "type": "boolean"
                },
                "background_sound_volume": {
                  "type": "number"
                },
                "llm_temperature": {
                  "type": "number"
                },
                "fallback_llm_enabled": {
                  "type": "boolean",
                  "nullable": true
                },
                "llm_fallback_delay_ms": {
                  "type": "number",
                  "nullable": true
                },
                "llm_fallback_model": {
                  "type": "string",
                  "nullable": true
                },
                "fallback_stt_enabled": {
                  "type": "boolean",
                  "nullable": true
                },
                "stt_fallback_wait_ms": {
                  "type": "number",
                  "nullable": true
                },
                "stt_fallback_transcriber_id": {
                  "type": "string",
                  "nullable": true
                },
                "predictive_preprocessing_enabled": {
                  "type": "boolean",
                  "nullable": true
                },
                "prompt_caching_enabled": {
                  "type": "boolean",
                  "nullable": true
                },
                "responsiveness": {
                  "type": "number"
                },
                "interruption_sensitivity": {
                  "type": "number"
                },
                "response_eagerness": {
                  "type": "number"
                },
                "transcriber_id": {
                  "type": "string",
                  "nullable": true
                },
                "denoising_mode": {
                  "type": "string",
                  "nullable": true
                },
                "denoise_strength": {
                  "type": "number",
                  "nullable": true
                },
                "boosted_keywords": {
                  "type": "string",
                  "nullable": true
                },
                "boost_dynamic_variables": {
                  "type": "boolean",
                  "nullable": true
                },
                "reminder_message_interval": {
                  "type": "number",
                  "nullable": true
                },
                "reminder_message_content": {
                  "type": "string",
                  "nullable": true
                },
                "default_dynamic_variables": {
                  "nullable": true
                },
                "call_transfer_settings": {
                  "nullable": true
                },
                "agent_identity": {
                  "type": "string",
                  "nullable": true
                },
                "agent_background": {
                  "type": "string",
                  "nullable": true
                },
                "node_positions": {
                  "type": "string",
                  "nullable": true
                },
                "ivr_menu": {
                  "type": "object",
                  "additionalProperties": true,
                  "nullable": true
                },
                "audio_cache_enabled": {
                  "type": "boolean",
                  "nullable": true
                },
                "language": {
                  "type": "object",
                  "nullable": true,
                  "additionalProperties": true,
                  "description": "Associated resource when configured. Included record; its own IDs are unprefixed."
                },
                "voice": {
                  "type": "object",
                  "nullable": true,
                  "additionalProperties": true,
                  "description": "Associated resource when configured. Included record; its own IDs are unprefixed."
                },
                "llm": {
                  "type": "object",
                  "nullable": true,
                  "additionalProperties": true,
                  "description": "Associated resource when configured. Included record; its own IDs are unprefixed."
                },
                "createdAt": {
                  "type": "string",
                  "format": "date-time"
                },
                "updatedAt": {
                  "type": "string",
                  "format": "date-time"
                },
                "end_call_on_hold_sec": {
                  "type": "integer",
                  "nullable": true,
                  "description": "Seconds to wait in a confirmed hold before hanging up; null when disabled."
                },
                "language_default_message": {
                  "type": "string",
                  "nullable": true,
                  "description": "Message spoken when the caller language is not supported."
                },
                "prompt_tokens": {
                  "type": "integer",
                  "nullable": true,
                  "description": "Token count of the stored prompt, when computed."
                },
                "secondary_language_ids": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  },
                  "description": "Additional language IDs the version can switch to."
                },
                "speech_to_speech_english_accent": {
                  "type": "string",
                  "enum": [
                    "indian",
                    "british",
                    "american"
                  ],
                  "description": "Accent of the agent's English on Speech-to-Speech calls: indian (default), british or american."
                },
                "pronunciations": {
                  "type": "array",
                  "description": "Pronunciation overrides for this version.",
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "agent_id": {
                        "type": "string",
                        "description": "Unprefixed agent ID."
                      },
                      "version_number": {
                        "type": "string"
                      },
                      "original_word": {
                        "type": "string"
                      },
                      "pronunciation_format": {
                        "type": "string"
                      },
                      "phonetic_pronunciation": {
                        "type": "string",
                        "nullable": true
                      },
                      "is_deleted": {
                        "type": "boolean"
                      },
                      "createdAt": {
                        "type": "string",
                        "format": "date-time"
                      },
                      "updatedAt": {
                        "type": "string",
                        "format": "date-time"
                      }
                    }
                  }
                },
                "postcall_analysis": {
                  "type": "array",
                  "description": "Post-call fields of this version. llm_id is the extraction LLM (null for the workspace default).",
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "field_name": {
                        "type": "string"
                      },
                      "field_description": {
                        "type": "string",
                        "nullable": true
                      },
                      "field_type": {
                        "type": "string",
                        "enum": [
                          "TEXT",
                          "SELECTOR",
                          "BOOLEAN",
                          "NUMBER",
                          "DATETIME"
                        ]
                      },
                      "agent_version_number": {
                        "type": "string"
                      },
                      "additional_fields": {
                        "nullable": true
                      },
                      "display_order": {
                        "type": "integer",
                        "nullable": true
                      },
                      "llm_id": {
                        "type": "string",
                        "nullable": true,
                        "example": "llm_A1B2C3D4E5F6G7"
                      }
                    }
                  }
                },
                "agent_functions": {
                  "type": "array",
                  "description": "Functions of this version. Returned by Get Agent, create and update; not by List Agents. agent_id is unprefixed.",
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "agent_id": {
                        "type": "string"
                      },
                      "version_number": {
                        "type": "string"
                      },
                      "display_name": {
                        "type": "string",
                        "nullable": true
                      },
                      "type": {
                        "type": "string"
                      },
                      "description": {
                        "type": "string",
                        "nullable": true
                      },
                      "config": {
                        "type": "object",
                        "additionalProperties": true,
                        "nullable": true
                      }
                    }
                  }
                }
              }
            }
          },
          "prompt_health": {
            "type": "object",
            "properties": {
              "status": {
                "type": "string",
                "enum": [
                  "green",
                  "yellow",
                  "red",
                  "over_ceiling",
                  "not_applicable"
                ]
              },
              "prompt_tokens": {
                "type": "integer",
                "description": "Estimated editable prompt tokens after expanding known defaults."
              },
              "limit_tokens": {
                "type": "integer"
              },
              "system_prompt_reserved_tokens": {
                "type": "integer"
              },
              "limited_by": {
                "type": "string",
                "nullable": true
              },
              "comment": {
                "type": "string"
              }
            },
            "description": "Reported by create and update. Single Prompt and Speech to Speech prompts receive model-dependent size guidance; other agent types report not_applicable."
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "description": "When the agent was created."
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "description": "When the agent record was last changed."
          },
          "organization_id": {
            "type": "string",
            "example": "o14XKPP84rt22g",
            "description": "Owning organization."
          },
          "is_deleted": {
            "type": "boolean",
            "description": "Whether the agent has been deleted. The list endpoint returns only agents where this is false."
          },
          "organization": {
            "type": "object",
            "description": "The owning organization record.",
            "properties": {
              "id": {
                "type": "string"
              },
              "title": {
                "type": "string"
              },
              "description": {
                "type": "string",
                "nullable": true
              },
              "status": {
                "type": "string"
              },
              "org_code": {
                "type": "string"
              },
              "createdAt": {
                "type": "string",
                "format": "date-time"
              },
              "updatedAt": {
                "type": "string",
                "format": "date-time"
              }
            }
          },
          "inbound_phone_numbers": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "example": "phn_abc123"
                },
                "phone_number": {
                  "type": "string",
                  "example": "9876543210",
                  "description": "The number without its country calling code."
                },
                "country_iso": {
                  "type": "string",
                  "example": "91",
                  "description": "Country calling code."
                },
                "nickname": {
                  "type": "string",
                  "nullable": true,
                  "description": "Label set in the dashboard."
                },
                "sip_trunk_enabled": {
                  "type": "boolean"
                },
                "linked_at": {
                  "type": "string",
                  "format": "date-time",
                  "nullable": true,
                  "description": "When the number was linked to the agent, when known."
                }
              },
              "required": [
                "id",
                "phone_number",
                "country_iso",
                "nickname",
                "sip_trunk_enabled",
                "linked_at"
              ]
            },
            "description": "Numbers that ring this agent. Up to 3."
          },
          "outbound_phone_numbers": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "example": "phn_abc123"
                },
                "phone_number": {
                  "type": "string",
                  "example": "9876543210",
                  "description": "The number without its country calling code."
                },
                "country_iso": {
                  "type": "string",
                  "example": "91",
                  "description": "Country calling code."
                },
                "nickname": {
                  "type": "string",
                  "nullable": true,
                  "description": "Label set in the dashboard."
                },
                "sip_trunk_enabled": {
                  "type": "boolean"
                },
                "linked_at": {
                  "type": "string",
                  "format": "date-time",
                  "nullable": true,
                  "description": "When the number was linked to the agent, when known."
                }
              },
              "required": [
                "id",
                "phone_number",
                "country_iso",
                "nickname",
                "sip_trunk_enabled",
                "linked_at"
              ]
            },
            "description": "Numbers the agent can call from. Up to 3."
          },
          "running_batches": {
            "type": "array",
            "description": "Returned only when the request publishes a draft (without update_deployment), and absent from the response otherwise: batches already running on this agent. They keep the version they were created with.",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "example": "batch_2g7Xy3tY53gRlp"
                },
                "title": {
                  "type": "string"
                },
                "agent_version_number": {
                  "type": "integer"
                }
              }
            }
          }
        },
        "required": [
          "id",
          "agent_type"
        ]
      },
      "CallLogs": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "call_abc123",
            "description": "Signed call ID"
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string",
              "maxLength": 40
            },
            "maxItems": 20
          }
        },
        "required": [
          "id"
        ]
      },
      "OrganizationFolder": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "f5k2m8x1q9w3zp"
          },
          "organization_id": {
            "type": "string",
            "example": "o14XKPP84rt22g"
          },
          "name": {
            "type": "string",
            "maxLength": 35,
            "example": "Sales Agents"
          },
          "is_deleted": {
            "type": "boolean",
            "example": false
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          },
          "organization": {
            "type": "object",
            "description": "The organization that owns the folder.",
            "properties": {
              "id": {
                "type": "string",
                "example": "o14XKPP84rt22g"
              },
              "title": {
                "type": "string",
                "example": "Acme Lending"
              }
            }
          }
        },
        "required": [
          "id",
          "organization_id",
          "name",
          "is_deleted",
          "createdAt",
          "updatedAt"
        ]
      },
      "PhoneCountryRule": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "c7r2n5x8q1w4zt"
          },
          "country_iso": {
            "type": "string",
            "minLength": 2,
            "maxLength": 2,
            "example": "IN"
          },
          "country_name": {
            "type": "string",
            "example": "India"
          },
          "calling_code": {
            "type": "string",
            "example": "91"
          },
          "max_length": {
            "type": "integer",
            "nullable": true,
            "example": 10
          },
          "prefixes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "example": [
              "98",
              "99"
            ]
          },
          "is_deleted": {
            "type": "boolean",
            "example": false
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "country_iso",
          "country_name",
          "calling_code",
          "prefixes",
          "is_deleted"
        ]
      },
      "EnabledTelephonyNetworkGroup": {
        "type": "object",
        "properties": {
          "prefix_mode": {
            "type": "string",
            "enum": [
              "allow_only_listed"
            ]
          },
          "from_phone_number_country_code": {
            "type": "string",
            "nullable": true,
            "example": null
          },
          "countryRule": {
            "type": "object",
            "properties": {
              "country_iso": {
                "type": "string",
                "example": "IN"
              },
              "country_name": {
                "type": "string",
                "example": "India Mobile",
                "description": "Name of the first enabled network group for the country, for example India Mobile. Not the country name."
              },
              "calling_code": {
                "type": "string",
                "example": "91"
              },
              "prefixes": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "example": [
                  "98",
                  "99"
                ]
              }
            },
            "required": [
              "country_iso",
              "country_name",
              "calling_code",
              "prefixes"
            ]
          }
        },
        "required": [
          "prefix_mode",
          "from_phone_number_country_code",
          "countryRule"
        ]
      },
      "PhoneNumberPricing": {
        "type": "object",
        "properties": {
          "telephony_provider_id": {
            "type": "string",
            "example": "mh00mke5j83neo"
          },
          "country_iso": {
            "type": "string",
            "minLength": 2,
            "maxLength": 3,
            "example": "IN"
          },
          "country_name": {
            "type": "string",
            "example": "India"
          },
          "credit_cost": {
            "type": "string",
            "example": "500.0000",
            "description": "Reference rental price as a decimal string with four decimal places."
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          },
          "telephonyProvider": {
            "type": "object",
            "additionalProperties": true,
            "description": "Associated telephony provider metadata."
          }
        },
        "required": [
          "telephony_provider_id",
          "country_iso",
          "country_name",
          "credit_cost"
        ]
      },
      "ErrorResponse": {
        "type": "object",
        "description": "Error body on endpoints without response filtering.",
        "properties": {
          "statusCode": {
            "type": "integer",
            "example": 404
          },
          "error": {
            "type": "boolean",
            "enum": [
              true
            ]
          },
          "success": {
            "type": "boolean",
            "enum": [
              false
            ]
          },
          "data": {
            "oneOf": [
              {
                "type": "object",
                "properties": {
                  "code": {
                    "type": "string",
                    "description": "Machine-readable refusal code."
                  }
                }
              },
              {
                "type": "array",
                "items": {}
              }
            ],
            "description": "For a coded refusal, an object with code and the details listed for that code. Otherwise an empty array."
          },
          "message": {
            "type": "string"
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Validation messages for a 400. Empty for other errors."
          },
          "validation_errors": {
            "type": "array",
            "description": "Present when uploaded rows fail number validation (batch and workflow lead uploads): one group per distinct error.",
            "items": {
              "type": "object",
              "properties": {
                "error": {
                  "type": "string"
                },
                "rows": {
                  "type": "array",
                  "items": {
                    "type": "integer"
                  },
                  "description": "Row numbers with this error."
                },
                "phone_numbers": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                }
              }
            }
          },
          "invalid_row_count": {
            "type": "integer",
            "description": "Present with validation_errors: how many rows failed."
          }
        },
        "required": [
          "statusCode",
          "error",
          "success",
          "data",
          "message",
          "errors"
        ]
      },
      "KnowledgeBase": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "kb_abc123",
            "description": "Signed knowledge base ID."
          },
          "name": {
            "type": "string",
            "example": "Loan FAQ",
            "maxLength": 150
          },
          "org_id": {
            "type": "string",
            "example": "o14XKPP84rt22g",
            "description": "Owning organization."
          },
          "is_deleted": {
            "type": "boolean",
            "description": "Whether the knowledge base has been deleted."
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "name"
        ]
      },
      "Languages": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "lang_abc123",
            "description": "Signed language ID"
          }
        },
        "required": [
          "id"
        ]
      },
      "Llm": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "llm_abc123",
            "description": "Signed LLM ID"
          }
        },
        "required": [
          "id"
        ]
      },
      "OrganizationPhoneNumber": {
        "type": "object",
        "properties": {
          "sip_trunk_enabled": {
            "type": "boolean",
            "description": "When true, Speech IO uses SIP trunking (e.g. asterisk) for this number.",
            "default": false
          }
        },
        "required": [
          "sip_trunk_enabled"
        ]
      },
      "Transcriber": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "trs_tr0soniox001xx"
          },
          "provider": {
            "type": "string",
            "example": "soniox",
            "description": "Speech-to-text provider."
          },
          "model_id": {
            "type": "string",
            "example": "stt-rt-v5",
            "description": "Provider model identifier."
          },
          "name": {
            "type": "string",
            "example": "Soniox STT RT v5"
          },
          "description": {
            "type": "string",
            "nullable": true
          },
          "supported_language_codes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "nullable": true,
            "description": "Language codes the model supports; null when the provider accepts any."
          },
          "provider_model_id": {
            "type": "string",
            "example": "pmd_798b2e5834",
            "nullable": true
          },
          "is_primary": {
            "type": "boolean",
            "description": "Selectable as the main transcriber."
          },
          "is_fallback": {
            "type": "boolean",
            "description": "Selectable as the fallback transcriber."
          },
          "is_deleted": {
            "type": "boolean"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "id"
        ]
      },
      "CreateAgentRequest": {
        "type": "object",
        "properties": {
          "voicemail_detection": {
            "type": "boolean",
            "description": "Indicates whether voicemail detection is enabled",
            "default": true,
            "example": true
          },
          "hangup_on_voicemail": {
            "type": "boolean",
            "description": "Hang up immediately when voicemail is detected instead of leaving a message",
            "default": true,
            "example": true
          },
          "lead_memory_enabled": {
            "type": "boolean",
            "description": "Show the lead's earlier successful calls in this workspace to the agent at the start of its next call with them. Not available on IVR agents: set it on the agents the menu connects to, which use it after the handoff",
            "default": false,
            "example": false
          },
          "lead_memory_save_enabled": {
            "type": "boolean",
            "description": "Save what was said on this agent's successful calls to lead memory, so agents in this workspace can use it on later calls with the same lead. Not available on IVR agents: set it on the agents the menu connects to, which save the call when the caller reaches them",
            "default": false,
            "example": false
          },
          "voicemail_message": {
            "type": "string",
            "description": "Message spoken when voicemail is detected (only used when hangup_on_voicemail is false). Supports Handlebars template syntax ({{variable}}). Must be valid Handlebars.",
            "example": "Hi, please call us back at your convenience."
          },
          "end_call_on_silence_sec": {
            "type": "number",
            "minimum": 15,
            "maximum": 30,
            "description": "Seconds of silence after which the call is automatically ended. Accepted range: 15 to 30 seconds. Must be at least 5 seconds above reminder_message_interval when reminders are configured.",
            "example": 20,
            "default": 15
          },
          "end_call_on_hold_sec": {
            "type": "number",
            "minimum": 10,
            "maximum": 60,
            "nullable": true,
            "example": 20,
            "description": "Seconds to wait during a sustained detected hold before ending a non-IVR call, 10 to 60. On create, omitted or null uses the default of 20."
          },
          "max_call_duration_sec": {
            "type": "number",
            "minimum": 60,
            "maximum": 5400,
            "description": "Maximum call duration in seconds before the call is forcibly ended. Maximum accepted: 3600 seconds for speech-to-speech agents, 5400 seconds for cascaded agents.",
            "example": 900,
            "default": 900
          },
          "ring_duration_sec": {
            "type": "number",
            "description": "Ring timeout for outbound Plivo calls in every workspace, default 30 seconds. Numeric input is rounded to a whole second and clamped to 10 through 30: 5 saves as 10, 90 as 30, and 22.6 as 23. Non-numeric input is rejected. Read the saved value after updating. Has no effect on inbound or web calls.",
            "example": 30,
            "default": 30
          },
          "background_sound": {
            "type": "string",
            "description": "Background sound identifier. When ambient_noise is on, calls play the built-in background track whatever value is set; set it to a value other than none for background_sound_volume to apply."
          },
          "background_sound_volume": {
            "type": "number",
            "default": 1,
            "minimum": 0,
            "maximum": 2,
            "description": "Volume of the background sound (0 to 2). Applied only when ambient_noise is true and background_sound is set to a value other than none."
          },
          "ambient_noise": {
            "type": "boolean",
            "default": true,
            "description": "Ambient noise playback on the call. On by default when omitted."
          },
          "responsiveness": {
            "type": "number",
            "default": 0,
            "minimum": 0,
            "maximum": 1,
            "description": "Seconds to wait after the caller stops speaking, 0 to 1. Stored on the agent version; not applied to calls."
          },
          "interruption_sensitivity": {
            "type": "number",
            "default": 0.5,
            "minimum": 0,
            "maximum": 1,
            "description": "Interruption sensitivity level (0 to 1). Stored on the agent version; not applied to calls."
          },
          "response_eagerness": {
            "type": "number",
            "minimum": 0,
            "maximum": 1,
            "description": "How eagerly the agent responds (0 to 1). Applied when the transcriber is Sarvam or Deepgram (Nova-2, Nova-3, Flux); Soniox agents ignore it. Defaults to 0.9 on create."
          },
          "listening_backchannel": {
            "type": "boolean",
            "default": false,
            "description": "When true, the agent plays short listening sounds (\"uh-huh\", \"right\") while the caller is still talking, so a long explanation is not met with silence. Independent of `backchanneling` (acknowledgements after the caller stops). Defaults to false."
          },
          "listening_backchannel_frequency": {
            "type": "number",
            "default": 0.8,
            "minimum": 0,
            "maximum": 1,
            "description": "How often a listening sound plays when one is possible, 0 (never) to 1 (every opportunity). Only used when listening_backchannel is true. Defaults to 0.8."
          },
          "denoising_mode": {
            "enum": [
              "remove_noise",
              "remove_noise_and_speech"
            ],
            "type": "string",
            "description": "Denoising mode. Only remove_noise turns denoising on; remove_noise_and_speech leaves it off. Web calls run without denoising."
          },
          "denoise_strength": {
            "type": "number",
            "minimum": 0,
            "maximum": 4,
            "description": "Noise suppression strength 0 to 4 (higher is stronger). Defaults to 1 on create."
          },
          "boosted_keywords": {
            "type": "string",
            "maxLength": 2000,
            "description": "Comma-separated list of words or phrases (e.g. \"DialNexa, NexaFlow, customer success\") used to bias the speech-to-text provider toward recognizing them correctly. This is a recognition bias, not a guarantee: it increases the likelihood of correctly transcribing uncommon names, brands, products, and domain vocabulary. Supported for Deepgram and Soniox transcribers (primary or fallback). Normalized to at most 100 unique terms (case-insensitive, duplicates removed, empty entries dropped) at the configuration boundary; empty/null means no boosted keywords."
          },
          "boost_dynamic_variables": {
            "type": "boolean",
            "default": false,
            "description": "When true, each call's dynamic-variable VALUES (from the test-call form or a batch-call CSV lead: names, cities, order IDs) are appended to boosted_keywords for that call, so per-call uncommon words get the same recognition bias. Values are sanitized first (punctuation stripped, over-long entries dropped) and never evict the agent's own configured terms, which always come first. Applies to Deepgram and Soniox only; defaults to false."
          },
          "reminder_message_interval": {
            "type": "number",
            "default": 10,
            "minimum": 0,
            "example": 10,
            "description": "Seconds of silence before a reminder. Zero disables reminders. Keep at least five seconds below end_call_on_silence_sec when enabled."
          },
          "reminder_message_content": {
            "type": "string",
            "nullable": true,
            "maxLength": 150,
            "description": "Reminder text spoken after reminder_message_interval seconds of silence, up to 150 characters. When unset, a language-appropriate default is spoken."
          },
          "transcriber_auto": {
            "type": "boolean",
            "description": "Auto transcriber: use the platform default STT pair for the agent languages, kept current as the defaults change. Omitting it gives a new agent Auto unless the request names a transcriber field; true ignores any transcriber fields sent with it."
          },
          "transcriber_id": {
            "type": "string",
            "nullable": true,
            "description": "ID of the transcriber catalog entry"
          },
          "fallback_stt_enabled": {
            "type": "boolean",
            "default": true,
            "description": "Run a fallback transcriber in parallel with the primary one. On create it defaults to on whenever DialNexa can pick a fallback transcriber for the agent's languages."
          },
          "stt_fallback_transcriber_id": {
            "type": "string",
            "nullable": true,
            "description": "Fallback transcriber. When omitted on create, DialNexa picks one suited to the agent's languages; it must differ from transcriber_id."
          },
          "stt_fallback_wait_ms": {
            "type": "number",
            "nullable": true,
            "minimum": 0,
            "description": "Milliseconds to wait for primary STT after fallback finalizes first"
          },
          "audio_cache_enabled": {
            "type": "boolean",
            "default": true,
            "description": "TTS audio caching for this agent. On by default; only DialNexa can turn it off, so sending false returns 403."
          },
          "emotion_tags_enabled": {
            "type": "boolean",
            "default": false,
            "description": "When true, the agent may write inline emotion tags (e.g. [sad], [excited]) that the voice performs. Supported only on Cartesia Sonic 3 and Soniox TTS v2 voices: turning it on for any other voice returns 400, and switching the voice to an unsupported one turns it off. Defaults to false."
          },
          "folder_id": {
            "type": "string",
            "description": "ID of the folder this agent belongs to",
            "example": "f5k2m8x1q9w3zp"
          },
          "goal": {
            "type": "string",
            "nullable": true,
            "maxLength": 2000,
            "description": "What the agent should achieve on a call, and optionally what counts as met or partly met. Blank or null = no goal."
          },
          "agent_type": {
            "enum": [
              "Single_Prompt_Agent",
              "Conversational_Flow_Agent",
              "IVR_Agent"
            ],
            "type": "string",
            "description": "Type of the agent",
            "example": "Single_Prompt_Agent",
            "default": "Single_Prompt_Agent"
          },
          "pipeline_type": {
            "enum": [
              "Cascaded",
              "Speech_To_Speech"
            ],
            "type": "string",
            "description": "Pipeline subtype for Single_Prompt_Agent. Cascaded = ASR→LLM→TTS pipeline. Speech_To_Speech = direct speech model. Null for Conversational_Flow_Agent.",
            "example": "Cascaded",
            "default": "Cascaded"
          },
          "title": {
            "type": "string",
            "minLength": 1,
            "maxLength": 70,
            "description": "Title of the agent, 1 to 70 characters. When omitted, DialNexa names it \"Nexa Agent N\", where N is one more than the number of agents ever created in the workspace, deleted ones included.",
            "example": "Customer Support Agent"
          },
          "version_title": {
            "type": "string",
            "nullable": true,
            "minLength": 1,
            "maxLength": 150,
            "description": "Version title, 1 to 150 characters. If omitted on create, the first version is titled \"Version 0\".",
            "example": null
          },
          "description": {
            "type": "string",
            "description": "Description of the agent",
            "example": "This agent handles customer support inquiries"
          },
          "timezone": {
            "type": "string",
            "description": "Timezone for the agent",
            "example": "Asia/Kolkata"
          },
          "llm_id": {
            "type": "string",
            "description": "ID of the primary LLM. When omitted, unknown, or a text model on a Speech to Speech agent, DialNexa uses its default model instead of returning an error; read the saved llm_id from the response.",
            "example": "llm_A1B2C3D4E5F6G7"
          },
          "language_id": {
            "type": "string",
            "description": "ID of the primary language. When omitted, DialNexa uses the language of the voice's model, or the platform default (Hinglish) when the voice has no single language.",
            "example": "lang_en_in"
          },
          "secondary_language_ids": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "maxItems": 3,
            "description": "Up to three additional language IDs in priority order. The chosen voice must support them. Send an empty array on update to clear."
          },
          "language_default_message": {
            "type": "string",
            "nullable": true,
            "maxLength": 500,
            "description": "Optional message for an unsupported caller language, up to 500 characters, spoken in the primary language voice."
          },
          "voice_id": {
            "type": "string",
            "description": "ID of the voice the agent speaks with. Use GET /v1/voices to browse available voices. When omitted, DialNexa uses its default voice. Speech to Speech agents always get a voice compatible with their model.",
            "example": "voice_abc123"
          },
          "prompt_text": {
            "type": "string",
            "description": "Main instructions for the agent. Supports Handlebars template syntax ({{variable}}) for dynamic content. Must be valid Handlebars: malformed syntax causes errors at call time.",
            "example": "Hello, how can I assist you today?"
          },
          "system_prompt_text": {
            "type": "string",
            "description": "Static system instructions. Template variables such as {{customer_name}} are rejected with 400; use prompt_text for dynamic content.",
            "example": "You are a helpful customer support agent named Sarah."
          },
          "ivr_menu": {
            "type": "object",
            "description": "IVR menu tree for IVR_Agent type: {entry_node, nodes{...}} with per-node prompt text + digit->node edges. Prompt audio is rendered + cached at publish."
          },
          "welcome_message": {
            "type": "string",
            "description": "Opening message spoken by the agent at the start of the call. Supports Handlebars template syntax ({{variable}}). Must be valid Handlebars: malformed syntax causes errors at call time.",
            "example": "Welcome to our service!"
          },
          "knowledge_base_ids": {
            "description": "IDs of the knowledge bases attached to this agent version",
            "example": [
              "kb_abc123",
              "kb_def456"
            ],
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "kb_max_chunks": {
            "type": "integer",
            "minimum": 1,
            "maximum": 10,
            "description": "Maximum number of RAG chunks to fetch (1 to 10)",
            "example": 5
          },
          "kb_min_score": {
            "type": "number",
            "minimum": 0,
            "maximum": 1,
            "description": "Minimum similarity score threshold for RAG results (0 to 1)",
            "example": 0.5
          },
          "default_dynamic_variables": {
            "type": "object",
            "description": "Default values for dynamic variables used in Handlebars templates. For call-transfer flows, the reserved key agent_transfer_destinations accepts a pipe-separated list of phone numbers (maximum 7). Each number must use a supported country code: US (+1) or India (+91), followed by exactly 10 digits (e.g. +11234567890|+919876543210).",
            "example": {
              "firstName": "John",
              "lastName": "Doe",
              "courseType": "Math"
            }
          },
          "voice_model_id": {
            "type": "string",
            "description": "Speech synthesis model for the selected voice. Each voice is tied to a specific provider, and only that provider's models are valid: submitting a model from a different provider will return 400. In most cases this field can be omitted; the recommended model for the chosen voice is applied automatically. For ElevenLabs voices, the supported model is eleven_flash_v2_5. To find supported models for a specific voice, call GET /v1/voices/{voice_id}/voice-models.",
            "example": "vm4k2p9x7q1z3r"
          },
          "voice_speed": {
            "type": "number",
            "minimum": 0.25,
            "maximum": 4,
            "description": "Voice speed from 0.25 to 4. Values outside this range return 400. Soniox voices clamp it to 0.7 to 1.3. Speech-to-Speech agents apply it on OpenAI Realtime models only; Gemini Live ignores it.",
            "example": 1
          },
          "speech_to_speech_english_accent": {
            "type": "string",
            "enum": [
              "indian",
              "british",
              "american"
            ],
            "description": "Accent of the agent's English on Speech-to-Speech calls, for the whole call: indian (default), british or american.",
            "default": "indian"
          },
          "voice_temperature": {
            "type": "number",
            "minimum": 0,
            "maximum": 2,
            "description": "Voice temperature from 0 to 2. Values outside this range return 400. Applied by ElevenLabs and Smallest voices only.",
            "example": 1
          },
          "voice_volume": {
            "type": "number",
            "minimum": -10,
            "maximum": 10,
            "description": "Voice volume from -10 to 10. Values outside this range return 400. Applied by Cartesia voices (a negative value plays as 1, maximum 2), Sarvam voices (below 0.1 plays as 1, maximum 3) and Speech-to-Speech agents; other providers ignore it. New agents default to -0.363.",
            "example": 0
          },
          "voice_pitch": {
            "type": "number",
            "minimum": -20,
            "maximum": 20,
            "description": "Voice pitch from -20 to 20. Values outside this range return 400. Applied by Sarvam voices only.",
            "example": 0
          },
          "llm_temperature": {
            "type": "number",
            "minimum": 0,
            "maximum": 2,
            "description": "LLM temperature from 0 to 2. Values outside this range return 400. Not applied to Speech-to-Speech agents.",
            "example": 1
          },
          "fallback_llm_enabled": {
            "type": "boolean",
            "description": "Enable fallback LLM for this agent",
            "example": false
          },
          "predictive_preprocessing_enabled": {
            "type": "boolean",
            "description": "Enable predictive preprocessing for this agent version. Not applied to Conversational Flow or Speech-to-Speech agents, or to web calls.",
            "example": false
          },
          "llm_fallback_delay_ms": {
            "type": "integer",
            "nullable": true,
            "minimum": 0,
            "description": "Milliseconds to wait before triggering the fallback LLM, a whole number of 0 or more.",
            "example": 200
          },
          "llm_fallback_model": {
            "type": "string",
            "nullable": true,
            "description": "ID of the LLM to use as fallback.",
            "example": "llm_A1B2C3D4E5F6G7"
          },
          "agent_functions": {
            "description": "Functions the agent can invoke during a call (e.g. end call, transfer, booking). Passed at create time; use PATCH to replace later.",
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "type": {
                  "type": "string",
                  "enum": [
                    "end_call",
                    "call_transfer",
                    "custom",
                    "check_calendar_availability",
                    "book_calendar",
                    "integration"
                  ]
                },
                "displayName": {
                  "type": "string"
                },
                "display_name": {
                  "type": "string",
                  "description": "Alias for displayName."
                },
                "description": {
                  "type": "string"
                },
                "config": {
                  "type": "object",
                  "additionalProperties": true
                }
              },
              "required": [
                "type"
              ]
            }
          },
          "post_call_analysis": {
            "description": "Fields to extract after a call. Names must be unique and SELECTOR fields need choices. On update, replaces the full list for the draft version.",
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "field_name": {
                  "type": "string",
                  "minLength": 1,
                  "pattern": "\\S",
                  "description": "Non-blank name, unique within this version."
                },
                "field_type": {
                  "type": "string",
                  "enum": [
                    "TEXT",
                    "SELECTOR",
                    "BOOLEAN",
                    "NUMBER",
                    "DATETIME"
                  ]
                },
                "field_description": {
                  "type": "string"
                },
                "additional_fields": {
                  "oneOf": [
                    {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    {
                      "type": "object",
                      "additionalProperties": true
                    }
                  ],
                  "nullable": true,
                  "description": "For SELECTOR, supply at least one non-blank string, normally as an array. An object with an options array is also accepted."
                },
                "display_order": {
                  "type": "integer",
                  "minimum": 0,
                  "description": "Defaults to the array index."
                }
              },
              "required": [
                "field_name",
                "field_type"
              ]
            }
          },
          "agent_identity": {
            "type": "string",
            "description": "Agent identity (required for Conversational_Flow_Agent type on update)",
            "example": "You are a helpful customer support agent named Sarah."
          },
          "agent_background": {
            "type": "string",
            "description": "Agent background (required for Conversational_Flow_Agent type on update)",
            "example": "You have 5 years of experience in customer support and specialize in helping customers with technical issues."
          },
          "post_call_analysis_llm_id": {
            "type": "string",
            "description": "LLM used for post-call field extraction. Accepts a prefixed ID (for example `llm_A1B2C3D4E5F6G7`) or a raw ID; null clears it so the default extraction model (gpt-4o-mini) is used. It is stored on the version's existing post-call fields, so it has no effect when the version has none, and a replaced post_call_analysis list creates new fields without it, so they use the default extraction model. On create it is applied to the fields sent in the same request.",
            "example": "llm_A1B2C3D4E5F6G7",
            "nullable": true
          },
          "pronunciations": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PronunciationItem"
            },
            "description": "Pronunciation overrides. Applied by ElevenLabs and Cartesia voices; other providers ignore them. Only items with phonetic_pronunciation are applied."
          }
        },
        "required": [
          "prompt_text"
        ]
      },
      "CreateCallRequest": {
        "type": "object",
        "properties": {
          "phone_number": {
            "type": "string",
            "example": "+911234567890",
            "description": "Phone number to call (must include country code). Format: +[country code][phone number]"
          },
          "agent_id": {
            "type": "string",
            "example": "agent_2g7Xy3tY53gRlp",
            "description": "Agent ID to use for the call. Must belong to the authenticated organization."
          },
          "agent_version_number": {
            "type": "number",
            "example": 2,
            "description": "Specific agent version number to use (optional). If provided, must be a published version. If not provided, will use the latest published version."
          },
          "phone_number_id": {
            "type": "string",
            "example": "phn_2g7Xy3tY53gRlp",
            "description": "One of the agent's outbound numbers to call from. Required when the agent has more than one outbound number."
          },
          "metadata": {
            "type": "object",
            "example": {
              "customer_name": "John Doe",
              "customer_email": "john@example.com",
              "priority": "high"
            },
            "description": "Metadata for the call including customer information and any additional context. This data will be available during the call for personalization."
          },
          "notes": {
            "type": "object",
            "example": {
              "customer_name": "John Doe",
              "follow_up_required": true,
              "source": "crm"
            },
            "description": "Optional notes stored on the call log. Must be a JSON object with at most 15 top-level keys."
          }
        },
        "required": [
          "phone_number",
          "agent_id",
          "metadata"
        ]
      },
      "CreateCallResponse": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "call_mfgsn90vwcozgb",
            "description": "Unique call ID for tracking. Use this ID to reference the call in other API endpoints."
          },
          "to_phone_number": {
            "type": "string",
            "example": "+911234567890",
            "description": "The phone number that will receive the call."
          },
          "agent_id": {
            "type": "string",
            "example": "agent_mfgsn90vwcozgb",
            "description": "The ID of the agent used for this call."
          },
          "agent_version_number": {
            "type": "number",
            "example": 2,
            "description": "Numeric agent version actually selected for this call. If omitted in the request, the latest published version is selected."
          }
        },
        "required": [
          "id",
          "to_phone_number",
          "agent_id"
        ]
      },
      "CreateKnowledgeBaseRequest": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 150,
            "pattern": "\\S",
            "description": "Knowledge base name, at most 150 characters and not blank.",
            "example": "Product Documentation"
          }
        },
        "required": [
          "name"
        ]
      },
      "CreateWebhookRequest": {
        "type": "object",
        "properties": {
          "url": {
            "type": "string",
            "format": "uri",
            "example": "https://webhook.site/your-endpoint",
            "description": "The URL to which webhook events will be sent."
          },
          "events": {
            "minItems": 1,
            "example": [
              "call.completed"
            ],
            "description": "List of events this webhook is subscribed to.",
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "is_active": {
            "type": "boolean",
            "example": true,
            "description": "Whether the webhook is active."
          },
          "secret": {
            "type": "string",
            "example": "replace-with-a-long-random-secret",
            "description": "Secret used to sign webhook payloads."
          }
        },
        "required": [
          "url",
          "events",
          "secret"
        ]
      },
      "LinkSipTrunkRequest": {
        "type": "object",
        "properties": {
          "phoneNumber": {
            "type": "string",
            "maxLength": 32,
            "example": "+14155552671",
            "description": "Phone number in E.164 form with the leading plus, for example +14155552671. It must be a valid number for its country."
          },
          "terminationUri": {
            "type": "string",
            "maxLength": 2048,
            "example": "31974861099010243.zt.plivo.com:5060",
            "description": "SIP termination host[:port]; must not use a sip: URI prefix"
          },
          "authMode": {
            "enum": [
              "userpass",
              "ip"
            ],
            "type": "string",
            "default": "userpass",
            "description": "How the provider authorizes this trunk. 'userpass' requires sipTrunkUserName and sipTrunkPassword; 'ip' requires both to be omitted and expects the provider to have whitelisted our signaling IP."
          },
          "sipTrunkUserName": {
            "type": "string",
            "maxLength": 512,
            "description": "SIP authentication username. Required for authMode=userpass, forbidden for ip."
          },
          "sipTrunkPassword": {
            "type": "string",
            "maxLength": 512,
            "description": "SIP authentication password stored encrypted. Required for authMode=userpass and forbidden for authMode=ip."
          },
          "nickname": {
            "type": "string",
            "maxLength": 255,
            "description": "Display nickname for this trunk"
          }
        },
        "required": [
          "phoneNumber",
          "terminationUri"
        ]
      },
      "AvailablePhoneNumber": {
        "type": "object",
        "properties": {
          "number": {
            "type": "string",
            "description": "The phone number, digits only, without a plus sign."
          },
          "type": {
            "type": "string",
            "description": "The type of phone number (local, tollfree, etc.)"
          },
          "monthly_rental_rate": {
            "type": "string",
            "description": "The monthly rental rate for the phone number"
          },
          "setup_rate": {
            "type": "string",
            "description": "The setup fee for the phone number"
          },
          "voice_enabled": {
            "type": "boolean",
            "description": "Voice capability of the phone number"
          },
          "sms_enabled": {
            "type": "boolean",
            "description": "SMS capability of the phone number"
          },
          "mms_enabled": {
            "type": "boolean",
            "description": "MMS capability of the phone number"
          },
          "country_iso": {
            "type": "string",
            "description": "Country ISO code"
          },
          "number_format": {
            "type": "string",
            "description": "The number as Plivo formats it."
          }
        },
        "required": [
          "number",
          "type",
          "monthly_rental_rate",
          "setup_rate",
          "voice_enabled",
          "sms_enabled",
          "mms_enabled",
          "country_iso",
          "number_format"
        ]
      },
      "AvailablePhoneNumbersResponse": {
        "type": "object",
        "properties": {
          "api_id": {
            "type": "string",
            "description": "API ID for the request"
          },
          "objects": {
            "description": "List of available phone numbers",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AvailablePhoneNumber"
            }
          },
          "meta": {
            "type": "object",
            "description": "Total count of available numbers"
          },
          "error": {
            "type": "string",
            "description": "Absent from the response when numbers are found. When Plivo has no numbers for the filters, its explanation, for example We are currently unable to offer your requested numbers; the status is still 200, objects is empty and meta.total_count is 0.",
            "example": "We are currently unable to offer your requested numbers"
          }
        },
        "required": [
          "api_id",
          "objects",
          "meta"
        ],
        "description": "Plivo's search response, passed through unchanged. Plivo can include fields beyond those listed here."
      },
      "PurchasePhoneNumberRequest": {
        "type": "object",
        "properties": {
          "phoneNumber": {
            "type": "string",
            "pattern": "^\\+?[1-9]\\d{5,14}$",
            "example": "+12025551234",
            "description": "Phone number to purchase: country code followed by the subscriber number, digits only, with or without a leading plus sign. Both +12025551234 and 12025551234 are accepted."
          },
          "telephonyProviderId": {
            "type": "string",
            "example": "mh00mke5j83neo",
            "description": "ID of telephony provider (14-char string)"
          },
          "countryISO": {
            "type": "string",
            "minLength": 2,
            "maxLength": 2,
            "pattern": "^[A-Z]{2}$",
            "example": "US",
            "description": "Uppercase two-letter country code of the number being bought, for example US. It must be the number's own country: a mismatch fails with 500 after the provider step."
          }
        },
        "required": [
          "phoneNumber",
          "telephonyProviderId",
          "countryISO"
        ]
      },
      "PurchasePhoneNumberResponse": {
        "type": "object",
        "properties": {
          "phoneNumber": {
            "type": "string",
            "example": "+14155552671",
            "description": "Phone number"
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "pending"
            ],
            "description": "Status of the phone number"
          },
          "message": {
            "type": "string",
            "description": "Status message"
          },
          "organizationPhoneNumber": {
            "description": "Organization phone number record",
            "allOf": [
              {
                "$ref": "#/components/schemas/OrganizationPhoneNumber"
              }
            ]
          }
        },
        "required": [
          "phoneNumber",
          "status"
        ]
      },
      "SpeechToSpeechLanguage": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "lang_mfgsys4f62f0vb"
          },
          "name": {
            "type": "string",
            "example": "Hindi"
          },
          "code": {
            "type": "string",
            "example": "hi"
          }
        },
        "required": [
          "id",
          "name",
          "code"
        ]
      },
      "SpeechToSpeechModel": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "llm_mj17v3n8k2q5wd"
          },
          "name": {
            "type": "string",
            "example": "GPT-realtime-2"
          },
          "provider": {
            "type": "string",
            "example": "openai"
          },
          "provider_id": {
            "type": "string",
            "example": "gpt-realtime-2"
          }
        },
        "required": [
          "id",
          "name",
          "provider",
          "provider_id"
        ]
      },
      "SpeechToSpeechVoice": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "voice_abc123456789"
          },
          "name": {
            "type": "string",
            "example": "Ash"
          },
          "provider": {
            "type": "string",
            "example": "openai",
            "nullable": true
          },
          "provider_voice_id": {
            "type": "string",
            "example": "ash",
            "nullable": true
          },
          "gender": {
            "type": "string",
            "example": "male"
          },
          "accent": {
            "type": "string",
            "example": "american",
            "nullable": true
          },
          "icon": {
            "type": "string",
            "nullable": true
          },
          "recording": {
            "type": "string",
            "nullable": true
          },
          "languages": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SpeechToSpeechLanguage"
            }
          },
          "llms": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SpeechToSpeechModel"
            }
          }
        },
        "required": [
          "id",
          "name",
          "provider",
          "provider_voice_id",
          "gender",
          "accent",
          "icon",
          "recording",
          "languages",
          "llms"
        ]
      },
      "SpeechToSpeechVoicesResponse": {
        "type": "object",
        "properties": {
          "voices": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SpeechToSpeechVoice"
            }
          }
        },
        "required": [
          "voices"
        ]
      },
      "UpdateAgentRequest": {
        "type": "object",
        "properties": {
          "background_sound": {
            "type": "string",
            "description": "Background sound identifier. When ambient_noise is on, calls play the built-in background track whatever value is set; set it to a value other than none for background_sound_volume to apply."
          },
          "background_sound_volume": {
            "type": "number",
            "minimum": 0,
            "maximum": 2,
            "description": "Volume of the background sound (0 to 2). Applied only when ambient_noise is true and background_sound is set to a value other than none."
          },
          "ambient_noise": {
            "type": "boolean",
            "description": "Enable or disable ambient noise playback on the call"
          },
          "responsiveness": {
            "type": "number",
            "minimum": 0,
            "maximum": 1,
            "description": "Seconds to wait after the caller stops speaking, 0 to 1. Stored on the agent version; not applied to calls."
          },
          "interruption_sensitivity": {
            "type": "number",
            "minimum": 0,
            "maximum": 1,
            "description": "Interruption sensitivity level (0 to 1). Stored on the agent version; not applied to calls."
          },
          "response_eagerness": {
            "type": "number",
            "minimum": 0,
            "maximum": 1,
            "description": "How eagerly the agent responds (0 to 1). Applied when the transcriber is Sarvam or Deepgram (Nova-2, Nova-3, Flux); Soniox agents ignore it."
          },
          "listening_backchannel": {
            "type": "boolean",
            "description": "Play listening sounds (uh-huh, right) while the caller is talking",
            "example": false
          },
          "listening_backchannel_frequency": {
            "type": "number",
            "minimum": 0,
            "maximum": 1,
            "description": "How often a listening sound plays when possible (0-1)",
            "example": 0.8
          },
          "denoising_mode": {
            "nullable": true,
            "type": "string",
            "enum": [
              "remove_noise",
              "remove_noise_and_speech"
            ],
            "description": "Denoising mode. Only remove_noise turns denoising on; remove_noise_and_speech leaves it off. Web calls run without denoising."
          },
          "denoise_strength": {
            "type": "number",
            "minimum": 0,
            "maximum": 4,
            "nullable": true,
            "description": "Noise suppression strength 0-4 (higher = stronger)"
          },
          "boosted_keywords": {
            "type": "string",
            "maxLength": 2000,
            "description": "Comma-separated list of words or phrases (e.g. \"DialNexa, NexaFlow, customer success\") used to bias the speech-to-text provider toward recognizing them correctly. This is a recognition bias, not a guarantee: it increases the likelihood of correctly transcribing uncommon names, brands, products, and domain vocabulary. Supported for Deepgram and Soniox transcribers (primary or fallback). Normalized to at most 100 unique terms (case-insensitive, duplicates removed, empty entries dropped) at the configuration boundary; empty/null means no boosted keywords."
          },
          "boost_dynamic_variables": {
            "type": "boolean",
            "description": "When true, each call's dynamic-variable VALUES (from the test-call form or a batch-call CSV lead: names, cities, order IDs) are appended to boosted_keywords for that call, so per-call uncommon words get the same recognition bias. Values are sanitized first (punctuation stripped, over-long entries dropped) and never evict the agent's own configured terms, which always come first. Applies to Deepgram and Soniox only; defaults to false."
          },
          "reminder_message_interval": {
            "type": "number",
            "minimum": 0,
            "example": 10,
            "description": "Seconds of silence before a reminder. Zero disables reminders. Keep at least five seconds below end_call_on_silence_sec when enabled."
          },
          "reminder_message_content": {
            "type": "string",
            "nullable": true,
            "maxLength": 150,
            "description": "Reminder text spoken after reminder_message_interval seconds of silence, up to 150 characters. When unset, a language-appropriate default is spoken. On update, null (and an empty string) is ignored and the stored value is kept: the update only writes fields that are not null or empty."
          },
          "transcriber_auto": {
            "type": "boolean",
            "description": "Auto transcriber: use the platform default STT pair for the agent languages, kept current as the defaults change. Setting any transcriber field without this turns Auto off; true ignores any transcriber fields sent with it."
          },
          "transcriber_id": {
            "type": "string",
            "nullable": true,
            "description": "ID of the transcriber catalog entry"
          },
          "fallback_stt_enabled": {
            "type": "boolean",
            "description": "Enable parallel fallback STT for this agent"
          },
          "stt_fallback_transcriber_id": {
            "type": "string",
            "nullable": true,
            "description": "Fallback STT transcriber catalog entry"
          },
          "stt_fallback_wait_ms": {
            "type": "number",
            "nullable": true,
            "minimum": 0,
            "description": "Milliseconds to wait for primary STT after fallback finalizes first"
          },
          "audio_cache_enabled": {
            "type": "boolean",
            "description": "TTS audio caching for this agent. Only DialNexa can disable it, so sending false returns 403. Omitting this field leaves the current value unchanged."
          },
          "emotion_tags_enabled": {
            "type": "boolean",
            "description": "When true, the agent may write inline emotion tags (e.g. [sad], [excited]) that the voice performs. Supported only on Cartesia Sonic 3 and Soniox TTS v2 voices: turning it on for any other voice returns 400, and switching the voice to an unsupported one turns it off. Defaults to false."
          },
          "voicemail_detection": {
            "type": "boolean",
            "description": "Indicates whether voicemail detection is enabled",
            "example": true
          },
          "hangup_on_voicemail": {
            "type": "boolean",
            "description": "Hang up immediately when voicemail is detected instead of leaving a message",
            "example": false
          },
          "lead_memory_enabled": {
            "type": "boolean",
            "description": "Show the lead's earlier successful calls in this workspace to the agent at the start of its next call with them. Not available on IVR agents: set it on the agents the menu connects to, which use it after the handoff",
            "example": false
          },
          "lead_memory_save_enabled": {
            "type": "boolean",
            "description": "Save what was said on this agent's successful calls to lead memory, so agents in this workspace can use it on later calls with the same lead. Not available on IVR agents: set it on the agents the menu connects to, which save the call when the caller reaches them",
            "example": false
          },
          "voicemail_message": {
            "type": "string",
            "description": "Message spoken when voicemail is detected (only used when hangup_on_voicemail is false). Supports Handlebars template syntax ({{variable}}). Must be valid Handlebars.",
            "example": "Hi, please call us back at your convenience."
          },
          "end_call_on_silence_sec": {
            "type": "number",
            "minimum": 15,
            "maximum": 30,
            "description": "Seconds of silence after which the call is automatically ended. Accepted range: 15 to 30 seconds. Must be at least 5 seconds above reminder_message_interval when reminders are configured.",
            "example": 20
          },
          "end_call_on_hold_sec": {
            "type": "number",
            "minimum": 10,
            "maximum": 60,
            "nullable": true,
            "example": 20,
            "description": "Seconds to wait during a sustained detected hold before ending a non-IVR call, 10 to 60. On update, null is ignored and the stored value is kept; an empty string fails validation and returns 400."
          },
          "max_call_duration_sec": {
            "type": "number",
            "minimum": 60,
            "maximum": 5400,
            "description": "Maximum call duration in seconds before the call is forcibly ended. Maximum accepted: 3600 seconds for speech-to-speech agents, 5400 seconds for cascaded agents.",
            "example": 600
          },
          "ring_duration_sec": {
            "type": "number",
            "description": "Ring timeout for outbound Plivo calls in every workspace, default 30 seconds. Numeric input is rounded to a whole second and clamped to 10 through 30: 5 saves as 10, 90 as 30, and 22.6 as 23. Non-numeric input is rejected. Read the saved value after updating. Has no effect on inbound or web calls.",
            "example": 30
          },
          "version_number": {
            "type": "integer",
            "description": "Version number to update, as a whole JSON number. current_version_number and version_number are returned as strings, so convert them before sending. A fractional value matches no version and returns 404.",
            "example": 1
          },
          "folder_id": {
            "type": "string",
            "description": "ID of the folder this agent belongs to",
            "example": "f5k2m8x1q9w3zp"
          },
          "pipeline_type": {
            "enum": [
              "Cascaded",
              "Speech_To_Speech"
            ],
            "type": "string",
            "description": "Pipeline subtype for Single_Prompt_Agent. Cascaded = ASR→LLM→TTS pipeline. Speech_To_Speech = direct speech model.",
            "example": "Cascaded"
          },
          "title": {
            "type": "string",
            "minLength": 1,
            "maxLength": 70,
            "description": "Title of the agent (max 70 characters)",
            "example": "Customer Support Agent"
          },
          "version_title": {
            "type": "string",
            "nullable": true,
            "minLength": 1,
            "maxLength": 150,
            "description": "Version title, 1 to 150 characters. If omitted on create, the first version is titled \"Version 0\". On update, null is ignored and the stored value is kept; an empty string fails validation and returns 400.",
            "example": "Version 1.1"
          },
          "description": {
            "type": "string",
            "description": "Description of the agent",
            "example": "This agent handles customer support inquiries"
          },
          "timezone": {
            "type": "string",
            "description": "Timezone for the agent",
            "example": "Asia/Kolkata"
          },
          "system_prompt_text": {
            "type": "string",
            "description": "Static system instructions. Template variables such as {{customer_name}} are rejected with 400; use prompt_text for dynamic content.",
            "example": "You are a helpful customer support agent named Sarah."
          },
          "language_id": {
            "type": "string",
            "description": "ID of the language the agent speaks",
            "example": "lang_en_in"
          },
          "secondary_language_ids": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "maxItems": 3,
            "description": "Up to three additional language IDs in priority order. The chosen voice must support them. Send an empty array on update to clear."
          },
          "language_default_message": {
            "type": "string",
            "nullable": true,
            "maxLength": 500,
            "description": "Optional message for an unsupported caller language, up to 500 characters, spoken in the primary language voice. On update, null (and an empty string) is ignored and the stored value is kept: the update only writes fields that are not null or empty."
          },
          "llm_id": {
            "type": "string",
            "description": "ID of the LLM associated with the agent",
            "example": "llm_A1B2C3D4E5F6G7"
          },
          "llm_temperature": {
            "type": "number",
            "minimum": 0,
            "maximum": 2,
            "description": "LLM temperature from 0 to 2. Values outside this range return 400. Not applied to Speech-to-Speech agents.",
            "example": 1
          },
          "voice_id": {
            "type": "string",
            "description": "ID of the voice the agent speaks with. Use GET /v1/voices to browse available voices.",
            "example": "voice_abc123"
          },
          "prompt_text": {
            "type": "string",
            "description": "Main instructions for the agent. Supports Handlebars template syntax ({{variable}}) for dynamic content. Must be valid Handlebars: malformed syntax causes errors at call time.",
            "example": "Hello, how can I assist you today?"
          },
          "ivr_menu": {
            "type": "object",
            "description": "IVR menu tree for IVR_Agent type: {entry_node, nodes{...}} with per-node prompt text + digit->node edges. Prompt audio is rendered + cached at publish."
          },
          "welcome_message": {
            "type": "string",
            "description": "Opening message spoken by the agent at the start of the call. Supports Handlebars template syntax ({{variable}}). Must be valid Handlebars: malformed syntax causes errors at call time.",
            "example": "Welcome to our service!"
          },
          "knowledge_base_ids": {
            "description": "IDs of the knowledge bases attached to this agent version",
            "example": [
              "kb_abc123",
              "kb_def456"
            ],
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "kb_max_chunks": {
            "type": "integer",
            "minimum": 1,
            "maximum": 10,
            "description": "Maximum number of RAG chunks to fetch (1 to 10)",
            "example": 5
          },
          "kb_min_score": {
            "type": "number",
            "minimum": 0,
            "maximum": 1,
            "description": "Minimum similarity score threshold for RAG results (0 to 1)",
            "example": 0.5
          },
          "is_published": {
            "type": "boolean",
            "description": "Whether this version is published",
            "example": false
          },
          "default_dynamic_variables": {
            "type": "object",
            "description": "Default values for dynamic variables used in Handlebars templates. For call-transfer flows, the reserved key agent_transfer_destinations accepts a pipe-separated list of phone numbers (maximum 7). Each number must use a supported country code: US (+1) or India (+91), followed by exactly 10 digits (e.g. +11234567890|+919876543210).",
            "example": {
              "firstName": "John",
              "lastName": "Doe",
              "courseType": "Math"
            }
          },
          "fallback_llm_enabled": {
            "type": "boolean",
            "description": "Enable fallback LLM for this agent",
            "example": false
          },
          "llm_fallback_delay_ms": {
            "type": "integer",
            "nullable": true,
            "minimum": 0,
            "description": "Milliseconds to wait before triggering the fallback LLM, a whole number of 0 or more. On update, null is ignored and the stored value is kept; an empty string fails validation and returns 400.",
            "example": 200
          },
          "llm_fallback_model": {
            "type": "string",
            "nullable": true,
            "description": "ID of the LLM to use as fallback. On update, null (and an empty string) is ignored and the stored value is kept: the update only writes fields that are not null or empty.",
            "example": "llm_A1B2C3D4E5F6G7"
          },
          "predictive_preprocessing_enabled": {
            "type": "boolean",
            "description": "Enable predictive preprocessing for this agent version. Not applied to Conversational Flow or Speech-to-Speech agents, or to web calls.",
            "example": false
          },
          "voice_model_id": {
            "type": "string",
            "description": "Speech synthesis model for the selected voice. Each voice is tied to a specific provider, and only that provider's models are valid: submitting a model from a different provider will return 400. In most cases this field can be omitted; the recommended model for the chosen voice is applied automatically. For ElevenLabs voices, the supported model is eleven_flash_v2_5. To find supported models for a specific voice, call GET /v1/voices/{voice_id}/voice-models.",
            "example": "vm4k2p9x7q1z3r"
          },
          "voice_speed": {
            "type": "number",
            "minimum": 0.25,
            "maximum": 4,
            "description": "Voice speed from 0.25 to 4. Values outside this range return 400. Soniox voices clamp it to 0.7 to 1.3. Speech-to-Speech agents apply it on OpenAI Realtime models only; Gemini Live ignores it.",
            "example": 1
          },
          "speech_to_speech_english_accent": {
            "type": "string",
            "enum": [
              "indian",
              "british",
              "american"
            ],
            "description": "Accent of the agent's English on Speech-to-Speech calls, for the whole call: indian (default), british or american."
          },
          "voice_temperature": {
            "type": "number",
            "minimum": 0,
            "maximum": 2,
            "description": "Voice temperature from 0 to 2. Values outside this range return 400. Applied by ElevenLabs and Smallest voices only.",
            "example": 1
          },
          "voice_volume": {
            "type": "number",
            "minimum": -10,
            "maximum": 10,
            "description": "Voice volume from -10 to 10. Values outside this range return 400. Applied by Cartesia voices (a negative value plays as 1, maximum 2), Sarvam voices (below 0.1 plays as 1, maximum 3) and Speech-to-Speech agents; other providers ignore it. New agents default to -0.363.",
            "example": 0
          },
          "voice_pitch": {
            "type": "number",
            "minimum": -20,
            "maximum": 20,
            "description": "Voice pitch from -20 to 20. Values outside this range return 400. Applied by Sarvam voices only.",
            "example": 0
          },
          "agent_identity": {
            "type": "string",
            "description": "Agent identity (required for Conversational_Flow_Agent type on update)",
            "example": "You are a helpful customer support agent named Sarah."
          },
          "agent_background": {
            "type": "string",
            "description": "Agent background (required for Conversational_Flow_Agent type on update)",
            "example": "You have 5 years of experience in customer support and specialize in helping customers with technical issues."
          },
          "post_call_analysis": {
            "description": "Fields to extract after a call. Names must be unique and SELECTOR fields need choices. On update, replaces the full list for the draft version.",
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "field_name": {
                  "type": "string",
                  "minLength": 1,
                  "pattern": "\\S",
                  "description": "Non-blank name, unique within this version."
                },
                "field_type": {
                  "type": "string",
                  "enum": [
                    "TEXT",
                    "SELECTOR",
                    "BOOLEAN",
                    "NUMBER",
                    "DATETIME"
                  ]
                },
                "field_description": {
                  "type": "string"
                },
                "additional_fields": {
                  "oneOf": [
                    {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    {
                      "type": "object",
                      "additionalProperties": true
                    }
                  ],
                  "nullable": true,
                  "description": "For SELECTOR, supply at least one non-blank string, normally as an array. An object with an options array is also accepted."
                },
                "display_order": {
                  "type": "integer",
                  "minimum": 0,
                  "description": "Defaults to the array index."
                }
              },
              "required": [
                "field_name",
                "field_type"
              ]
            }
          },
          "agent_functions": {
            "description": "Agent functions for this version. The list replaces the existing functions, except the platform end_call function, which is always kept. Pass an empty array to remove the others.",
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "type": {
                  "type": "string",
                  "enum": [
                    "end_call",
                    "call_transfer",
                    "custom",
                    "check_calendar_availability",
                    "book_calendar",
                    "integration"
                  ]
                },
                "displayName": {
                  "type": "string"
                },
                "display_name": {
                  "type": "string",
                  "description": "Alias for displayName."
                },
                "description": {
                  "type": "string"
                },
                "config": {
                  "type": "object",
                  "additionalProperties": true
                }
              },
              "required": [
                "type"
              ]
            }
          },
          "post_call_analysis_llm_id": {
            "type": "string",
            "nullable": true,
            "description": "LLM used for post-call field extraction. Accepts a prefixed ID (for example `llm_A1B2C3D4E5F6G7`) or a raw ID; null clears it so the default extraction model (gpt-4o-mini) is used. It is stored on the version's existing post-call fields, so it has no effect when the version has none, and a replaced post_call_analysis list creates new fields without it, so they use the default extraction model. It is saved before the rest of the update is validated, so a request that is then rejected (400, 403 or 409) can still have changed it.",
            "example": "llm_A1B2C3D4E5F6G7"
          },
          "pronunciations": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PronunciationItem"
            },
            "description": "Pronunciation overrides. Applied by ElevenLabs and Cartesia voices; other providers ignore them. Only items with phonetic_pronunciation are applied."
          }
        },
        "required": [
          "version_number"
        ]
      },
      "UpdateKnowledgeBaseRequest": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "pattern": "\\S",
            "description": "Knowledge base name. Must not be blank when provided. Keep it to 150 characters: a longer name is refused with 500.",
            "example": "Updated Product Documentation"
          }
        }
      },
      "UpdateWebhookRequest": {
        "type": "object",
        "properties": {
          "url": {
            "type": "string",
            "format": "uri",
            "example": "https://webhook.site/updated-endpoint",
            "description": "The new URL for the webhook."
          },
          "events": {
            "minItems": 1,
            "example": [
              "call.completed"
            ],
            "description": "Updated list of events.",
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "is_active": {
            "type": "boolean",
            "example": false,
            "description": "Whether the webhook is active."
          },
          "secret": {
            "type": "string",
            "example": "replace-with-a-new-long-random-secret",
            "description": "New secret for signing payloads."
          }
        }
      },
      "KnowledgeBaseDocument": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Document ID (raw, no prefix)."
          },
          "title": {
            "type": "string"
          },
          "knowledge_base_id": {
            "type": "string",
            "description": "Knowledge base ID without the kb_ prefix."
          },
          "description": {
            "type": "string"
          },
          "content": {
            "type": "string",
            "description": "Full text extracted from the file."
          },
          "source": {
            "type": "string"
          },
          "document_type": {
            "type": "string"
          },
          "file_path": {
            "type": "string",
            "description": "Storage path of the uploaded file."
          },
          "file_size": {
            "type": "number",
            "description": "File size in KB (1024 bytes)."
          },
          "is_deleted": {
            "type": "boolean"
          },
          "ingest_status": {
            "type": "string",
            "enum": [
              "processing",
              "ready",
              "failed"
            ],
            "description": "Indexing state: processing until indexing finishes, then ready. A document whose indexing fails is marked failed with ingest_error set and deleted at the same time, so it leaves the document list and can be uploaded again under the same title."
          },
          "ingest_error": {
            "type": "string",
            "nullable": true
          },
          "ingest_updated_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "ingest_job_id": {
            "type": "string",
            "nullable": true,
            "description": "Identifier of the current indexing attempt."
          }
        }
      },
      "RunAgentBuilder": {
        "type": "object",
        "properties": {
          "structured_input": {
            "description": "Structured blueprint submission - each field has a description (field guidance) and value (user answer)",
            "allOf": [
              {
                "$ref": "#/components/schemas/StructuredBlueprintInput"
              }
            ]
          },
          "build_attempt": {
            "type": "integer",
            "description": "Build attempt number (1-2). Validation runs only on attempt 1; attempt 2 skips re-validation.",
            "minimum": 1,
            "maximum": 2,
            "default": 1
          },
          "pipeline": {
            "type": "string",
            "description": "Engine for the generated agent. \"s2s\" builds the realtime pipeline on the same single-prompt agent; anything else builds the cascaded pipeline.",
            "enum": [
              "cascaded",
              "s2s"
            ],
            "default": "cascaded"
          },
          "target_shape": {
            "type": "string",
            "description": "Kind of agent to build. \"cfa\" writes a conversation-flow document (a step graph), \"ivr\" writes a touch-tone menu; anything else builds a single-prompt agent.",
            "enum": [
              "spa",
              "cfa",
              "ivr"
            ],
            "default": "spa"
          }
        },
        "required": [
          "structured_input"
        ]
      },
      "StructuredBlueprintInput": {
        "type": "object",
        "properties": {
          "company_and_offering": {
            "$ref": "#/components/schemas/StructuredBlueprintField"
          },
          "target_customer": {
            "$ref": "#/components/schemas/StructuredBlueprintField"
          },
          "primary_goal": {
            "$ref": "#/components/schemas/StructuredBlueprintField"
          },
          "success_criteria": {
            "$ref": "#/components/schemas/StructuredBlueprintField"
          },
          "information_to_collect": {
            "$ref": "#/components/schemas/StructuredBlueprintField"
          },
          "objections_and_faqs": {
            "$ref": "#/components/schemas/StructuredBlueprintField"
          },
          "agent_tone": {
            "$ref": "#/components/schemas/StructuredBlueprintField"
          },
          "additional_context": {
            "$ref": "#/components/schemas/StructuredBlueprintField"
          },
          "validation_clarifications": {
            "$ref": "#/components/schemas/StructuredBlueprintField"
          }
        },
        "required": [
          "company_and_offering",
          "target_customer",
          "primary_goal",
          "success_criteria",
          "information_to_collect",
          "objections_and_faqs",
          "agent_tone",
          "additional_context"
        ]
      },
      "StructuredBlueprintField": {
        "type": "object",
        "properties": {
          "description": {
            "type": "string",
            "description": "User-facing explanation of what this field is asking for",
            "example": "Share your company name and a short description of your product, service, or industry."
          },
          "value": {
            "type": "string",
            "description": "User-provided answer for this field",
            "example": "Acme Corp: we sell B2B payroll software for mid-market HR teams."
          }
        },
        "required": [
          "description",
          "value"
        ]
      },
      "GenerateObjectives": {
        "type": "object",
        "properties": {
          "company_and_offering": {
            "type": "string",
            "description": "Company name and what the business offers",
            "example": "Acme Corp - B2B payroll software for mid-market HR teams."
          },
          "target_customer": {
            "type": "string",
            "description": "Who the agent will speak with",
            "example": "HR directors at 200-2,000 employee companies evaluating payroll vendors."
          },
          "primary_goal": {
            "type": "string",
            "description": "Primary outcome the agent should achieve on each call",
            "example": "Book demos and answer pricing and onboarding questions."
          }
        },
        "required": [
          "company_and_offering",
          "target_customer",
          "primary_goal"
        ]
      },
      "GenerateAgentTone": {
        "type": "object",
        "properties": {
          "company_and_offering": {
            "type": "string"
          },
          "target_customer": {
            "type": "string"
          },
          "primary_goal": {
            "type": "string"
          },
          "success_criteria": {
            "type": "string"
          },
          "information_to_collect": {
            "type": "string"
          },
          "objections_and_faqs": {
            "type": "string"
          }
        },
        "required": [
          "company_and_offering",
          "target_customer",
          "primary_goal",
          "success_criteria",
          "information_to_collect",
          "objections_and_faqs"
        ]
      },
      "PromptReviewRequest": {
        "type": "object",
        "properties": {
          "checks": {
            "type": "array",
            "description": "Check groups to run. Omit for all. unknowable, conflicts, structure and speech call a model; leave all four out to avoid model work.",
            "items": {
              "type": "string",
              "enum": [
                "structure",
                "variables",
                "speech",
                "unknowable",
                "conflicts",
                "language",
                "models",
                "capture",
                "call_handling"
              ]
            }
          },
          "prompt_text": {
            "type": "string",
            "description": "Prompt text to review instead of the stored prompt, up to 100,000 characters. Empty or whitespace falls back to the stored prompt. The version must still exist in your workspace.",
            "maxLength": 100000
          }
        }
      },
      "PromptReviewAcknowledgementRequest": {
        "type": "object",
        "properties": {
          "finding_fingerprint": {
            "type": "string",
            "description": "The finding's own fingerprint (sha1 hex), from the review response.",
            "pattern": "^[0-9a-f]{40}$"
          },
          "kind": {
            "type": "string",
            "description": "The finding kind at ack time (contradiction, hallucination_risk, ...).",
            "maxLength": 40
          },
          "status": {
            "type": "string",
            "enum": [
              "accepted",
              "dismissed"
            ]
          }
        },
        "required": [
          "finding_fingerprint",
          "kind",
          "status"
        ]
      },
      "ShapeAdvisorRequest": {
        "type": "object",
        "properties": {
          "description": {
            "type": "string",
            "maxLength": 2000,
            "description": "Plain-language description of what the phone agent should do on calls",
            "example": "Callers pick a department with key presses, then a conversation books their visit."
          }
        },
        "required": [
          "description"
        ]
      },
      "UpdateBatchCallStatusRequest": {
        "type": "object",
        "properties": {
          "action": {
            "type": "string",
            "enum": [
              "pause",
              "resume",
              "cancel"
            ],
            "description": "pause stops new outbound calls and keeps the batch resumable; resume re-enqueues the remaining leads; cancel removes queued calls and cannot be resumed. cancel works from any state except completed or cancelled, including running.",
            "example": "pause"
          }
        },
        "required": [
          "action"
        ]
      },
      "UpdateWorkflowStatusRequest": {
        "type": "object",
        "properties": {
          "action": {
            "type": "string",
            "enum": [
              "activate",
              "deactivate",
              "pause",
              "resume"
            ],
            "description": "activate validates the workflow, sets it active and starts leads without an execution; deactivate and pause set it paused, which stops new lead starts and holds queued calls until it is active again, but does not stop leads already in a step from advancing; resume sets a paused workflow active without starting leads added while paused.",
            "example": "activate"
          }
        },
        "required": [
          "action"
        ]
      },
      "GenerateObjectivesRequest": {
        "type": "object",
        "properties": {
          "company_and_offering": {
            "type": "string",
            "description": "Company name and what the business offers",
            "example": "Acme Corp: B2B payroll software for mid-market HR teams."
          },
          "target_customer": {
            "type": "string",
            "description": "Who the agent will speak with",
            "example": "HR directors at 200 to 2,000 employee companies evaluating payroll vendors."
          },
          "primary_goal": {
            "type": "string",
            "description": "Primary outcome the agent should achieve on each call",
            "example": "Book demos and answer pricing and onboarding questions."
          }
        },
        "required": [
          "company_and_offering",
          "target_customer",
          "primary_goal"
        ]
      },
      "RunAgentBuilderRequest": {
        "type": "object",
        "properties": {
          "structured_input": {
            "description": "Structured blueprint submission: each field has a description (field guidance) and value (user answer)",
            "allOf": [
              {
                "$ref": "#/components/schemas/StructuredBlueprintInput"
              }
            ]
          },
          "build_attempt": {
            "type": "number",
            "minimum": 1,
            "maximum": 2,
            "description": "Build attempt number (1 to 2). Validation runs only on attempt 1; attempt 2 skips re-validation.",
            "default": 1
          },
          "pipeline": {
            "type": "string",
            "enum": [
              "cascaded",
              "s2s"
            ],
            "description": "Engine for the generated agent. \"s2s\" builds the realtime pipeline on the same single-prompt agent; anything else builds the cascaded pipeline.",
            "default": "cascaded"
          },
          "target_shape": {
            "type": "string",
            "enum": [
              "spa",
              "cfa",
              "ivr"
            ],
            "description": "Kind of agent to build. \"cfa\" writes a conversation-flow document (a step graph), \"ivr\" writes a touch-tone menu; anything else builds a single-prompt agent.",
            "default": "spa"
          }
        },
        "required": [
          "structured_input"
        ]
      },
      "GenerateAgentToneRequest": {
        "type": "object",
        "properties": {
          "company_and_offering": {
            "type": "string"
          },
          "target_customer": {
            "type": "string"
          },
          "primary_goal": {
            "type": "string"
          },
          "success_criteria": {
            "type": "string"
          },
          "information_to_collect": {
            "type": "string"
          },
          "objections_and_faqs": {
            "type": "string"
          }
        },
        "required": [
          "company_and_offering",
          "target_customer",
          "primary_goal",
          "success_criteria",
          "information_to_collect",
          "objections_and_faqs"
        ]
      },
      "ClassifyShapeRequest": {
        "type": "object",
        "properties": {
          "company_and_offering": {
            "type": "string",
            "maxLength": 4000,
            "example": "A motor insurance provider handling accident claims."
          },
          "target_customer": {
            "type": "string",
            "maxLength": 4000,
            "example": "Policyholders calling after an accident."
          },
          "primary_goal": {
            "type": "string",
            "maxLength": 4000,
            "example": "Take first notice of loss and log the claim."
          },
          "success_criteria": {
            "type": "string",
            "maxLength": 4000,
            "example": "All the claim details are captured and logged."
          },
          "information_to_collect": {
            "type": "string",
            "maxLength": 4000,
            "example": "Full name, date of birth, policy number"
          },
          "objections_and_faqs": {
            "type": "string",
            "maxLength": 4000,
            "example": "Why is my premium going up, how long does a claim take"
          },
          "agent_tone": {
            "type": "string",
            "maxLength": 4000,
            "example": "Calm, clear and reassuring."
          },
          "additional_context": {
            "type": "string",
            "maxLength": 4000,
            "example": "Never quote a settlement amount on the call."
          },
          "language": {
            "type": "string",
            "maxLength": 120,
            "description": "Language name as shown in the picker",
            "example": "English"
          }
        }
      },
      "PostCallAnalysisItem": {
        "type": "object",
        "properties": {
          "field_name": {
            "type": "string",
            "pattern": "^(?!_nexa_)",
            "example": "customer_satisfaction",
            "description": "Unique within the version. Must not be blank or start with \"_nexa_\" (reserved for system fields)."
          },
          "field_type": {
            "type": "string",
            "enum": [
              "TEXT",
              "SELECTOR",
              "BOOLEAN",
              "NUMBER",
              "DATETIME"
            ],
            "example": "NUMBER"
          },
          "field_description": {
            "type": "string",
            "example": "Customer satisfaction rating from 1 to 5"
          },
          "additional_fields": {
            "description": "Choices for SELECTOR (required, at least one) or example values for TEXT. Normally an array of strings.",
            "example": [
              "Resolved",
              "Escalated"
            ],
            "oneOf": [
              {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              {
                "type": "object",
                "additionalProperties": true
              }
            ]
          },
          "display_order": {
            "type": "number",
            "minimum": 0,
            "example": 0,
            "description": "Position in the list; defaults to the array index."
          }
        },
        "required": [
          "field_name",
          "field_type"
        ]
      },
      "PronunciationItem": {
        "type": "object",
        "properties": {
          "original_word": {
            "type": "string",
            "maxLength": 128,
            "description": "Word",
            "example": "Nexa"
          },
          "pronunciation_format": {
            "type": "string",
            "maxLength": 128,
            "description": "Pronunciation",
            "example": "Nek-sa"
          },
          "phonetic_pronunciation": {
            "type": "string",
            "maxLength": 128,
            "description": "Approx pronunciation",
            "example": "Nek-sa"
          }
        },
        "required": [
          "original_word",
          "pronunciation_format"
        ]
      },
      "AgentFunctionItem": {
        "type": "object",
        "properties": {
          "displayName": {
            "type": "string",
            "example": "Book Calendar",
            "description": "Label shown in the dashboard."
          },
          "display_name": {
            "type": "string",
            "example": "Book Calendar",
            "description": "Alias for displayName (snake_case)."
          },
          "type": {
            "type": "string",
            "enum": [
              "end_call",
              "call_transfer",
              "custom",
              "check_calendar_availability",
              "book_calendar",
              "integration"
            ],
            "example": "book_calendar"
          },
          "description": {
            "type": "string",
            "example": "Books a calendar appointment for the caller"
          },
          "config": {
            "type": "object",
            "additionalProperties": true,
            "example": {
              "calendar_id": "primary"
            }
          }
        },
        "required": [
          "type"
        ]
      },
      "AgentRecord": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "agent_2g7Xy3tY53gRlp",
            "description": "Signed agent ID"
          },
          "folder_id": {
            "type": "string",
            "nullable": true
          },
          "current_version_number": {
            "type": "string",
            "example": "3",
            "description": "Number of the current version. Serialized as a string (the column is a 64-bit integer)."
          },
          "timezone": {
            "type": "string",
            "nullable": true
          },
          "agent_type": {
            "type": "string",
            "enum": [
              "Single_Prompt_Agent",
              "Conversational_Flow_Agent",
              "IVR_Agent"
            ]
          },
          "pipeline_type": {
            "type": "string",
            "enum": [
              "Cascaded",
              "Speech_To_Speech"
            ],
            "nullable": true
          },
          "webhook_id": {
            "type": "string",
            "nullable": true
          },
          "current_version": {
            "type": "object",
            "nullable": true,
            "description": "The version current_version_number points to.",
            "properties": {
              "agent_id": {
                "type": "string"
              },
              "version_number": {
                "type": "string",
                "example": "1",
                "description": "Version number. Serialized as a string (the column is a 64-bit integer)."
              },
              "version_title": {
                "type": "string",
                "nullable": true
              },
              "title": {
                "type": "string",
                "nullable": true
              },
              "description": {
                "type": "string",
                "nullable": true
              },
              "llm_id": {
                "type": "string",
                "nullable": true
              },
              "language_id": {
                "type": "string"
              },
              "voice_id": {
                "type": "string"
              },
              "voice_model_id": {
                "type": "string",
                "nullable": true
              },
              "voice_speed": {
                "type": "number",
                "nullable": true
              },
              "voice_temperature": {
                "type": "number",
                "nullable": true
              },
              "voice_volume": {
                "type": "number",
                "nullable": true
              },
              "voice_pitch": {
                "type": "number",
                "nullable": true
              },
              "prompt_text": {
                "type": "string"
              },
              "system_prompt_text": {
                "type": "string",
                "nullable": true
              },
              "conversation_start_type": {
                "type": "string"
              },
              "welcome_message": {
                "type": "string",
                "nullable": true
              },
              "knowledge_base_ids": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "nullable": true
              },
              "kb_max_chunks": {
                "type": "number",
                "nullable": true
              },
              "kb_min_score": {
                "type": "number",
                "nullable": true
              },
              "is_published": {
                "type": "boolean"
              },
              "voicemail_detection": {
                "type": "boolean",
                "nullable": true
              },
              "hangup_on_voicemail": {
                "type": "boolean",
                "nullable": true
              },
              "voicemail_message": {
                "type": "string",
                "nullable": true
              },
              "end_call_on_silence_sec": {
                "type": "number"
              },
              "max_call_duration_sec": {
                "type": "number"
              },
              "ring_duration_sec": {
                "type": "number"
              },
              "background_sound": {
                "type": "string",
                "nullable": true
              },
              "ambient_noise": {
                "type": "boolean"
              },
              "background_sound_volume": {
                "type": "number"
              },
              "llm_temperature": {
                "type": "number"
              },
              "fallback_llm_enabled": {
                "type": "boolean",
                "nullable": true
              },
              "llm_fallback_delay_ms": {
                "type": "number",
                "nullable": true
              },
              "llm_fallback_model": {
                "type": "string",
                "nullable": true
              },
              "fallback_stt_enabled": {
                "type": "boolean",
                "nullable": true
              },
              "stt_fallback_wait_ms": {
                "type": "number",
                "nullable": true
              },
              "stt_fallback_transcriber_id": {
                "type": "string",
                "nullable": true
              },
              "predictive_preprocessing_enabled": {
                "type": "boolean",
                "nullable": true
              },
              "prompt_caching_enabled": {
                "type": "boolean",
                "nullable": true
              },
              "responsiveness": {
                "type": "number"
              },
              "interruption_sensitivity": {
                "type": "number"
              },
              "response_eagerness": {
                "type": "number"
              },
              "transcriber_id": {
                "type": "string",
                "nullable": true
              },
              "denoising_mode": {
                "type": "string",
                "nullable": true
              },
              "denoise_strength": {
                "type": "number",
                "nullable": true
              },
              "boosted_keywords": {
                "type": "string",
                "nullable": true
              },
              "boost_dynamic_variables": {
                "type": "boolean",
                "nullable": true
              },
              "reminder_message_interval": {
                "type": "number",
                "nullable": true
              },
              "reminder_message_content": {
                "type": "string",
                "nullable": true
              },
              "default_dynamic_variables": {
                "nullable": true
              },
              "call_transfer_settings": {
                "nullable": true
              },
              "agent_identity": {
                "type": "string",
                "nullable": true
              },
              "agent_background": {
                "type": "string",
                "nullable": true
              },
              "node_positions": {
                "type": "string",
                "nullable": true
              },
              "ivr_menu": {
                "type": "object",
                "additionalProperties": true,
                "nullable": true
              },
              "audio_cache_enabled": {
                "type": "boolean",
                "nullable": true
              },
              "language": {
                "type": "object",
                "nullable": true,
                "additionalProperties": true,
                "description": "Associated resource when configured. Included record; its own IDs are unprefixed."
              },
              "voice": {
                "type": "object",
                "nullable": true,
                "additionalProperties": true,
                "description": "Associated resource when configured. Included record; its own IDs are unprefixed."
              },
              "llm": {
                "type": "object",
                "nullable": true,
                "additionalProperties": true,
                "description": "Associated resource when configured. Included record; its own IDs are unprefixed."
              },
              "createdAt": {
                "type": "string",
                "format": "date-time"
              },
              "updatedAt": {
                "type": "string",
                "format": "date-time"
              },
              "end_call_on_hold_sec": {
                "type": "integer",
                "nullable": true,
                "description": "Seconds to wait in a confirmed hold before hanging up; null when disabled."
              },
              "language_default_message": {
                "type": "string",
                "nullable": true,
                "description": "Message spoken when the caller language is not supported."
              },
              "prompt_tokens": {
                "type": "integer",
                "nullable": true,
                "description": "Token count of the stored prompt, when computed."
              },
              "secondary_language_ids": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "Additional language IDs the version can switch to."
              },
              "speech_to_speech_english_accent": {
                "type": "string",
                "enum": [
                  "indian",
                  "british",
                  "american"
                ],
                "description": "Accent of the agent's English on Speech-to-Speech calls: indian (default), british or american."
              },
              "pronunciations": {
                "type": "array",
                "description": "Pronunciation overrides for this version.",
                "items": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "agent_id": {
                      "type": "string",
                      "description": "Unprefixed agent ID."
                    },
                    "version_number": {
                      "type": "string"
                    },
                    "original_word": {
                      "type": "string"
                    },
                    "pronunciation_format": {
                      "type": "string"
                    },
                    "phonetic_pronunciation": {
                      "type": "string",
                      "nullable": true
                    },
                    "is_deleted": {
                      "type": "boolean"
                    },
                    "createdAt": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "updatedAt": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                }
              },
              "postcall_analysis": {
                "type": "array",
                "description": "Post-call fields of this version. llm_id is the extraction LLM (null for the workspace default).",
                "items": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "field_name": {
                      "type": "string"
                    },
                    "field_description": {
                      "type": "string",
                      "nullable": true
                    },
                    "field_type": {
                      "type": "string",
                      "enum": [
                        "TEXT",
                        "SELECTOR",
                        "BOOLEAN",
                        "NUMBER",
                        "DATETIME"
                      ]
                    },
                    "agent_version_number": {
                      "type": "string"
                    },
                    "additional_fields": {
                      "nullable": true
                    },
                    "display_order": {
                      "type": "integer",
                      "nullable": true
                    },
                    "llm_id": {
                      "type": "string",
                      "nullable": true,
                      "example": "llm_A1B2C3D4E5F6G7"
                    }
                  }
                }
              },
              "agent_functions": {
                "type": "array",
                "description": "Functions of this version. Returned by Get Agent, create and update; not by List Agents. agent_id is unprefixed.",
                "items": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "agent_id": {
                      "type": "string"
                    },
                    "version_number": {
                      "type": "string"
                    },
                    "display_name": {
                      "type": "string",
                      "nullable": true
                    },
                    "type": {
                      "type": "string"
                    },
                    "description": {
                      "type": "string",
                      "nullable": true
                    },
                    "config": {
                      "type": "object",
                      "additionalProperties": true,
                      "nullable": true
                    }
                  }
                }
              }
            }
          },
          "versions": {
            "type": "array",
            "description": "Every version, newest first.",
            "items": {
              "type": "object",
              "properties": {
                "agent_id": {
                  "type": "string"
                },
                "version_number": {
                  "type": "string",
                  "example": "1",
                  "description": "Version number. Serialized as a string (the column is a 64-bit integer)."
                },
                "version_title": {
                  "type": "string",
                  "nullable": true
                },
                "title": {
                  "type": "string",
                  "nullable": true
                },
                "description": {
                  "type": "string",
                  "nullable": true
                },
                "llm_id": {
                  "type": "string",
                  "nullable": true
                },
                "language_id": {
                  "type": "string"
                },
                "voice_id": {
                  "type": "string"
                },
                "voice_model_id": {
                  "type": "string",
                  "nullable": true
                },
                "voice_speed": {
                  "type": "number",
                  "nullable": true
                },
                "voice_temperature": {
                  "type": "number",
                  "nullable": true
                },
                "voice_volume": {
                  "type": "number",
                  "nullable": true
                },
                "voice_pitch": {
                  "type": "number",
                  "nullable": true
                },
                "prompt_text": {
                  "type": "string"
                },
                "system_prompt_text": {
                  "type": "string",
                  "nullable": true
                },
                "conversation_start_type": {
                  "type": "string"
                },
                "welcome_message": {
                  "type": "string",
                  "nullable": true
                },
                "knowledge_base_ids": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  },
                  "nullable": true
                },
                "kb_max_chunks": {
                  "type": "number",
                  "nullable": true
                },
                "kb_min_score": {
                  "type": "number",
                  "nullable": true
                },
                "is_published": {
                  "type": "boolean"
                },
                "voicemail_detection": {
                  "type": "boolean",
                  "nullable": true
                },
                "hangup_on_voicemail": {
                  "type": "boolean",
                  "nullable": true
                },
                "voicemail_message": {
                  "type": "string",
                  "nullable": true
                },
                "end_call_on_silence_sec": {
                  "type": "number"
                },
                "max_call_duration_sec": {
                  "type": "number"
                },
                "ring_duration_sec": {
                  "type": "number"
                },
                "background_sound": {
                  "type": "string",
                  "nullable": true
                },
                "ambient_noise": {
                  "type": "boolean"
                },
                "background_sound_volume": {
                  "type": "number"
                },
                "llm_temperature": {
                  "type": "number"
                },
                "fallback_llm_enabled": {
                  "type": "boolean",
                  "nullable": true
                },
                "llm_fallback_delay_ms": {
                  "type": "number",
                  "nullable": true
                },
                "llm_fallback_model": {
                  "type": "string",
                  "nullable": true
                },
                "fallback_stt_enabled": {
                  "type": "boolean",
                  "nullable": true
                },
                "stt_fallback_wait_ms": {
                  "type": "number",
                  "nullable": true
                },
                "stt_fallback_transcriber_id": {
                  "type": "string",
                  "nullable": true
                },
                "predictive_preprocessing_enabled": {
                  "type": "boolean",
                  "nullable": true
                },
                "prompt_caching_enabled": {
                  "type": "boolean",
                  "nullable": true
                },
                "responsiveness": {
                  "type": "number"
                },
                "interruption_sensitivity": {
                  "type": "number"
                },
                "response_eagerness": {
                  "type": "number"
                },
                "transcriber_id": {
                  "type": "string",
                  "nullable": true
                },
                "denoising_mode": {
                  "type": "string",
                  "nullable": true
                },
                "denoise_strength": {
                  "type": "number",
                  "nullable": true
                },
                "boosted_keywords": {
                  "type": "string",
                  "nullable": true
                },
                "boost_dynamic_variables": {
                  "type": "boolean",
                  "nullable": true
                },
                "reminder_message_interval": {
                  "type": "number",
                  "nullable": true
                },
                "reminder_message_content": {
                  "type": "string",
                  "nullable": true
                },
                "default_dynamic_variables": {
                  "nullable": true
                },
                "call_transfer_settings": {
                  "nullable": true
                },
                "agent_identity": {
                  "type": "string",
                  "nullable": true
                },
                "agent_background": {
                  "type": "string",
                  "nullable": true
                },
                "node_positions": {
                  "type": "string",
                  "nullable": true
                },
                "ivr_menu": {
                  "type": "object",
                  "additionalProperties": true,
                  "nullable": true
                },
                "audio_cache_enabled": {
                  "type": "boolean",
                  "nullable": true
                },
                "language": {
                  "type": "object",
                  "nullable": true,
                  "additionalProperties": true,
                  "description": "Associated resource when configured. Included record; its own IDs are unprefixed."
                },
                "voice": {
                  "type": "object",
                  "nullable": true,
                  "additionalProperties": true,
                  "description": "Associated resource when configured. Included record; its own IDs are unprefixed."
                },
                "llm": {
                  "type": "object",
                  "nullable": true,
                  "additionalProperties": true,
                  "description": "Associated resource when configured. Included record; its own IDs are unprefixed."
                },
                "createdAt": {
                  "type": "string",
                  "format": "date-time"
                },
                "updatedAt": {
                  "type": "string",
                  "format": "date-time"
                },
                "end_call_on_hold_sec": {
                  "type": "integer",
                  "nullable": true,
                  "description": "Seconds to wait in a confirmed hold before hanging up; null when disabled."
                },
                "language_default_message": {
                  "type": "string",
                  "nullable": true,
                  "description": "Message spoken when the caller language is not supported."
                },
                "prompt_tokens": {
                  "type": "integer",
                  "nullable": true,
                  "description": "Token count of the stored prompt, when computed."
                },
                "secondary_language_ids": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  },
                  "description": "Additional language IDs the version can switch to."
                },
                "speech_to_speech_english_accent": {
                  "type": "string",
                  "enum": [
                    "indian",
                    "british",
                    "american"
                  ],
                  "description": "Accent of the agent's English on Speech-to-Speech calls: indian (default), british or american."
                },
                "pronunciations": {
                  "type": "array",
                  "description": "Pronunciation overrides for this version.",
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "agent_id": {
                        "type": "string",
                        "description": "Unprefixed agent ID."
                      },
                      "version_number": {
                        "type": "string"
                      },
                      "original_word": {
                        "type": "string"
                      },
                      "pronunciation_format": {
                        "type": "string"
                      },
                      "phonetic_pronunciation": {
                        "type": "string",
                        "nullable": true
                      },
                      "is_deleted": {
                        "type": "boolean"
                      },
                      "createdAt": {
                        "type": "string",
                        "format": "date-time"
                      },
                      "updatedAt": {
                        "type": "string",
                        "format": "date-time"
                      }
                    }
                  }
                },
                "postcall_analysis": {
                  "type": "array",
                  "description": "Post-call fields of this version. llm_id is the extraction LLM (null for the workspace default).",
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "field_name": {
                        "type": "string"
                      },
                      "field_description": {
                        "type": "string",
                        "nullable": true
                      },
                      "field_type": {
                        "type": "string",
                        "enum": [
                          "TEXT",
                          "SELECTOR",
                          "BOOLEAN",
                          "NUMBER",
                          "DATETIME"
                        ]
                      },
                      "agent_version_number": {
                        "type": "string"
                      },
                      "additional_fields": {
                        "nullable": true
                      },
                      "display_order": {
                        "type": "integer",
                        "nullable": true
                      },
                      "llm_id": {
                        "type": "string",
                        "nullable": true,
                        "example": "llm_A1B2C3D4E5F6G7"
                      }
                    }
                  }
                },
                "agent_functions": {
                  "type": "array",
                  "description": "Functions of this version. Returned by Get Agent, create and update; not by List Agents. agent_id is unprefixed.",
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "agent_id": {
                        "type": "string"
                      },
                      "version_number": {
                        "type": "string"
                      },
                      "display_name": {
                        "type": "string",
                        "nullable": true
                      },
                      "type": {
                        "type": "string"
                      },
                      "description": {
                        "type": "string",
                        "nullable": true
                      },
                      "config": {
                        "type": "object",
                        "additionalProperties": true,
                        "nullable": true
                      }
                    }
                  }
                }
              }
            }
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "description": "When the agent was created."
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "description": "When the agent record was last changed."
          },
          "organization_id": {
            "type": "string",
            "example": "o14XKPP84rt22g",
            "description": "Owning organization."
          },
          "is_deleted": {
            "type": "boolean",
            "description": "Whether the agent has been deleted. The list endpoint returns only agents where this is false."
          },
          "organization": {
            "type": "object",
            "description": "The owning organization record.",
            "properties": {
              "id": {
                "type": "string"
              },
              "title": {
                "type": "string"
              },
              "description": {
                "type": "string",
                "nullable": true
              },
              "status": {
                "type": "string"
              },
              "org_code": {
                "type": "string"
              },
              "createdAt": {
                "type": "string",
                "format": "date-time"
              },
              "updatedAt": {
                "type": "string",
                "format": "date-time"
              }
            }
          }
        },
        "required": [
          "id",
          "agent_type"
        ],
        "description": "An agent as stored. Returned by the list and get endpoints."
      },
      "PhoneNumberRecord": {
        "type": "object",
        "description": "A phone number owned by the workspace, as stored. Returned by the list and get endpoints.",
        "properties": {
          "id": {
            "type": "string",
            "example": "phn_mfk3p8z2c4v6bn",
            "description": "Signed phone number ID."
          },
          "phone_number": {
            "type": "string",
            "example": "9876543210",
            "pattern": "^[0-9]+$",
            "description": "National number without the country calling code or a plus sign, as a string of digits. Build the E.164 form as + followed by country_iso and phone_number."
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "active"
            ],
            "description": "Provisioning status of the number."
          },
          "country_iso": {
            "type": "string",
            "example": "91",
            "description": "Country calling code without the plus sign, for example 91 or 1. This is not an ISO country code."
          },
          "telephony_provider_id": {
            "type": "string",
            "description": "Telephony provider the number belongs to."
          },
          "organization_id": {
            "type": "string",
            "description": "Owning organization."
          },
          "inbound_agent_id": {
            "type": "string",
            "nullable": true,
            "description": "Agent that answers inbound calls on this number, on its latest published version; null when none is linked."
          },
          "outbound_agent_id": {
            "type": "string",
            "nullable": true,
            "description": "Agent that can call from this number; null when none is linked."
          },
          "rental_start_date": {
            "type": "string",
            "format": "date",
            "nullable": true,
            "example": "2026-09-17"
          },
          "rental_end_date": {
            "type": "string",
            "format": "date",
            "nullable": true,
            "example": "2026-10-17"
          },
          "rental_status": {
            "type": "string",
            "nullable": true,
            "enum": [
              "active",
              "expired",
              "available_for_reassignment"
            ]
          },
          "sip_trunk_enabled": {
            "type": "boolean",
            "description": "Whether a SIP trunk is linked to this number."
          },
          "nickname": {
            "type": "string",
            "nullable": true,
            "description": "Label set in the dashboard."
          },
          "is_deleted": {
            "type": "boolean"
          },
          "deleted_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "deleted_by": {
            "type": "string",
            "nullable": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "phone_number",
          "status"
        ]
      },
      "CodedErrorResponse": {
        "type": "object",
        "description": "Error body for a coded refusal; data carries code and its details.",
        "properties": {
          "statusCode": {
            "type": "integer",
            "example": 404
          },
          "error": {
            "type": "boolean",
            "enum": [
              true
            ]
          },
          "success": {
            "type": "boolean",
            "enum": [
              false
            ]
          },
          "data": {
            "oneOf": [
              {
                "type": "object",
                "properties": {
                  "code": {
                    "type": "string",
                    "description": "Machine-readable refusal code."
                  }
                }
              },
              {
                "type": "array",
                "items": {}
              }
            ],
            "description": "For a coded refusal, an object with code and the details listed for that code. Otherwise an empty array."
          },
          "message": {
            "type": "string"
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Validation messages for a 400. Empty for other errors."
          },
          "validation_errors": {
            "type": "array",
            "description": "Present when uploaded rows fail number validation (batch and workflow lead uploads): one group per distinct error.",
            "items": {
              "type": "object",
              "properties": {
                "error": {
                  "type": "string"
                },
                "rows": {
                  "type": "array",
                  "items": {
                    "type": "integer"
                  },
                  "description": "Row numbers with this error."
                },
                "phone_numbers": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                }
              }
            }
          },
          "invalid_row_count": {
            "type": "integer",
            "description": "Present with validation_errors: how many rows failed."
          }
        },
        "required": [
          "statusCode",
          "error",
          "success",
          "data",
          "message",
          "errors"
        ]
      },
      "LinkAgentPhoneNumberRequest": {
        "type": "object",
        "properties": {
          "phone_number_id": {
            "type": "string",
            "description": "Organization phone number to attach",
            "example": "phn_2g7Xy3tY53gRlp"
          },
          "direction": {
            "type": "string",
            "enum": [
              "inbound",
              "outbound"
            ]
          },
          "move": {
            "type": "boolean",
            "default": false,
            "description": "Move the number here when another agent holds it in this direction. That agent loses it in the same request, under the same rules as detaching it there."
          }
        },
        "required": [
          "phone_number_id",
          "direction"
        ]
      },
      "UpdateBatchCallPhoneNumberRequest": {
        "type": "object",
        "properties": {
          "phone_number_id": {
            "type": "string",
            "description": "One of the batch's agent's outbound numbers to dial from.",
            "example": "phn_2g7Xy3tY53gRlp"
          }
        },
        "required": [
          "phone_number_id"
        ]
      },
      "FilteredErrorResponse": {
        "type": "object",
        "description": "Error body on calls, batch calls, voices, languages and LLMs, which return only the message (and data for a coded refusal).",
        "properties": {
          "message": {
            "type": "string"
          },
          "data": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "description": "Machine-readable refusal code."
              }
            },
            "description": "Present for a coded refusal: code and the details listed for that code."
          },
          "validation_errors": {
            "type": "array",
            "description": "Present when uploaded rows fail number validation (batch and workflow lead uploads): one group per distinct error.",
            "items": {
              "type": "object",
              "properties": {
                "error": {
                  "type": "string"
                },
                "rows": {
                  "type": "array",
                  "items": {
                    "type": "integer"
                  },
                  "description": "Row numbers with this error."
                },
                "phone_numbers": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                }
              }
            }
          },
          "invalid_row_count": {
            "type": "integer",
            "description": "Present with validation_errors: how many rows failed."
          }
        },
        "required": [
          "message"
        ]
      },
      "AgentEvalTest": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "agent_id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "folder": {
            "type": "string",
            "nullable": true
          },
          "type": {
            "type": "string",
            "enum": [
              "next_reply",
              "tool_call",
              "simulation"
            ]
          },
          "config": {
            "type": "object",
            "additionalProperties": true
          },
          "template_id": {
            "type": "string",
            "nullable": true
          },
          "enabled": {
            "type": "boolean"
          },
          "last_result": {
            "type": "object",
            "properties": {
              "run_id": {
                "type": "string"
              },
              "passed": {
                "type": "integer"
              },
              "total": {
                "type": "integer"
              },
              "finished_at": {
                "type": "string",
                "format": "date-time",
                "nullable": true
              },
              "version_number": {
                "type": "integer",
                "nullable": true
              },
              "target": {
                "type": "string",
                "nullable": true
              }
            },
            "nullable": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "agent_id",
          "name",
          "type",
          "config",
          "enabled"
        ]
      },
      "AgentEvalRun": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "agent_id": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "queued",
              "running",
              "completed",
              "cancelled"
            ]
          },
          "target": {
            "type": "string",
            "enum": [
              "draft",
              "published"
            ]
          },
          "version_number": {
            "type": "integer"
          },
          "trigger": {
            "type": "string",
            "enum": [
              "manual",
              "pre_publish"
            ]
          },
          "repeat": {
            "type": "integer"
          },
          "mode": {
            "type": "string",
            "enum": [
              "text",
              "voice"
            ]
          },
          "llm": {
            "type": "string",
            "enum": [
              "primary",
              "secondary",
              "both"
            ]
          },
          "test_ids": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "passed": {
            "type": "integer"
          },
          "failed": {
            "type": "integer"
          },
          "errored": {
            "type": "integer"
          },
          "total": {
            "type": "integer"
          },
          "cost_inr": {
            "type": "number",
            "nullable": true
          },
          "duration_ms": {
            "type": "integer",
            "nullable": true
          },
          "insights": {
            "type": "object",
            "additionalProperties": true,
            "nullable": true
          },
          "insights_status": {
            "type": "string",
            "nullable": true,
            "enum": [
              "pending",
              "ready",
              "failed",
              null
            ]
          },
          "created_by_name": {
            "type": "string",
            "nullable": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "finished_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          }
        },
        "required": [
          "id",
          "agent_id",
          "status",
          "target",
          "mode",
          "llm",
          "test_ids",
          "total"
        ]
      },
      "AgentEvalRunDetail": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "agent_id": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "queued",
              "running",
              "completed",
              "cancelled"
            ]
          },
          "target": {
            "type": "string",
            "enum": [
              "draft",
              "published"
            ]
          },
          "version_number": {
            "type": "integer"
          },
          "trigger": {
            "type": "string",
            "enum": [
              "manual",
              "pre_publish"
            ]
          },
          "repeat": {
            "type": "integer"
          },
          "mode": {
            "type": "string",
            "enum": [
              "text",
              "voice"
            ]
          },
          "llm": {
            "type": "string",
            "enum": [
              "primary",
              "secondary",
              "both"
            ]
          },
          "test_ids": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "passed": {
            "type": "integer"
          },
          "failed": {
            "type": "integer"
          },
          "errored": {
            "type": "integer"
          },
          "total": {
            "type": "integer"
          },
          "cost_inr": {
            "type": "number",
            "nullable": true
          },
          "duration_ms": {
            "type": "integer",
            "nullable": true
          },
          "insights": {
            "type": "object",
            "additionalProperties": true,
            "nullable": true
          },
          "insights_status": {
            "type": "string",
            "nullable": true,
            "enum": [
              "pending",
              "ready",
              "failed",
              null
            ]
          },
          "created_by_name": {
            "type": "string",
            "nullable": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "finished_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "conversations": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AgentEvalConversationSummary"
            }
          }
        },
        "required": [
          "id",
          "agent_id",
          "status",
          "target",
          "mode",
          "llm",
          "test_ids",
          "total"
        ]
      },
      "AgentEvalConversationSummary": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "test_id": {
            "type": "string"
          },
          "attempt": {
            "type": "integer"
          },
          "language": {
            "type": "object",
            "additionalProperties": true,
            "nullable": true
          },
          "llm": {
            "type": "object",
            "additionalProperties": true,
            "nullable": true
          },
          "outcome": {
            "type": "string",
            "nullable": true,
            "enum": [
              "pass",
              "fail",
              "error",
              null
            ]
          },
          "failure_reason": {
            "type": "string",
            "nullable": true
          },
          "status": {
            "type": "string",
            "enum": [
              "queued",
              "calling",
              "judging",
              "scoring",
              "completed"
            ]
          },
          "summary": {
            "type": "string",
            "nullable": true
          },
          "turns": {
            "type": "integer"
          },
          "last_turn": {
            "type": "object",
            "additionalProperties": true,
            "nullable": true
          }
        },
        "required": [
          "id",
          "test_id",
          "attempt",
          "status"
        ]
      },
      "AgentEvalConversation": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "test_id": {
            "type": "string"
          },
          "attempt": {
            "type": "integer"
          },
          "language": {
            "type": "object",
            "additionalProperties": true,
            "nullable": true
          },
          "llm": {
            "type": "object",
            "additionalProperties": true,
            "nullable": true
          },
          "outcome": {
            "type": "string",
            "nullable": true,
            "enum": [
              "pass",
              "fail",
              "error",
              null
            ]
          },
          "failure_reason": {
            "type": "string",
            "nullable": true
          },
          "status": {
            "type": "string",
            "enum": [
              "queued",
              "calling",
              "judging",
              "scoring",
              "completed"
            ]
          },
          "summary": {
            "type": "string",
            "nullable": true
          },
          "test_name": {
            "type": "string"
          },
          "test_type": {
            "type": "string",
            "enum": [
              "next_reply",
              "tool_call",
              "simulation"
            ]
          },
          "run_id": {
            "type": "string"
          },
          "transcript": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          },
          "criteria": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          },
          "params": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          },
          "outcomes": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          },
          "builtin": {
            "type": "object",
            "additionalProperties": true,
            "nullable": true
          },
          "example_comparison": {
            "type": "object",
            "additionalProperties": true,
            "nullable": true
          },
          "language_signals": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          },
          "extracted_fields": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          },
          "error_message": {
            "type": "string",
            "nullable": true
          },
          "ended_reason": {
            "type": "string",
            "nullable": true
          },
          "recording_url": {
            "type": "string",
            "nullable": true
          },
          "latency_p50_ms": {
            "type": "number",
            "nullable": true
          },
          "latency_p90_ms": {
            "type": "number",
            "nullable": true
          },
          "judge_feedback": {
            "type": "string",
            "nullable": true,
            "enum": [
              "agree",
              "disagree",
              null
            ]
          }
        },
        "required": [
          "id",
          "test_id",
          "attempt",
          "status"
        ]
      },
      "SaveAgentEvalTest": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 200,
            "description": "Test name. Surrounding whitespace is removed."
          },
          "folder": {
            "type": "string",
            "maxLength": 100,
            "nullable": true,
            "description": "Optional folder. Omit, send null or an empty string to use no folder."
          },
          "type": {
            "type": "string",
            "enum": [
              "next_reply",
              "tool_call",
              "simulation"
            ]
          },
          "config": {
            "type": "object",
            "additionalProperties": true,
            "description": "Test definition for the selected type. Use a scenario and criteria for a simulation, or history and criteria for a reply check. Saved as supplied; saving does not run the test."
          }
        },
        "required": [
          "name",
          "type",
          "config"
        ]
      },
      "StartAgentEvalRun": {
        "type": "object",
        "properties": {
          "test_ids": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "minItems": 1,
            "description": "Saved test IDs belonging to this agent. Disabled tests are excluded."
          },
          "repeat": {
            "type": "integer",
            "minimum": 1,
            "maximum": 20
          },
          "target": {
            "type": "string",
            "enum": [
              "draft",
              "published"
            ],
            "description": "draft selects the newest saved version; published selects the published version."
          },
          "prompt_override": {
            "type": "string",
            "description": "Optional editor prompt for draft runs. Ignored for a published target."
          },
          "trigger": {
            "type": "string",
            "enum": [
              "manual",
              "pre_publish"
            ],
            "default": "manual",
            "description": "Run label. pre_publish does not publish the agent or block publishing."
          },
          "mode": {
            "type": "string",
            "enum": [
              "text",
              "voice"
            ],
            "default": "text",
            "description": "Text skips speech recognition and synthesis. Voice uses the audio test-call path."
          },
          "llm": {
            "type": "string",
            "enum": [
              "primary",
              "secondary",
              "both"
            ],
            "default": "primary",
            "description": "Primary keeps the version configuration, including fallback. Secondary uses the enabled fallback model alone. Both queues each test for each model; requires an enabled fallback model. Other settings stay the same."
          }
        },
        "required": [
          "test_ids",
          "repeat",
          "target"
        ]
      }
    }
  }
}
