{
  "openapi": "3.0.1",
  "info": {
    "title": "ChatDash Webhook API Documentation",
    "description": "API Documentation for the ChatDash Webhook Subscription System",
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "https://api.chat-dash.com/v1/public"
    }
  ],
  "paths": {
    "/clients/{clientId}/phone-numbers": {
      "get": {
        "tags": ["Phone Numbers"],
        "summary": "Get Phone Numbers",
        "description": "Retrieve a list of phone numbers for the specified client",
        "parameters": [
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "description": "Client-specific API key for authentication",
            "schema": {
              "type": "string",
              "pattern": "^CD\\.CL\\."
            }
          },
          {
            "name": "clientId",
            "in": "path",
            "required": true,
            "description": "Client ID to retrieve phone numbers for",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "agentId",
            "in": "query",
            "required": true,
            "description": "Filter phone numbers by associated agent ID",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/PhoneNumber"
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error",
            "content": {}
          }
        }
      }
    },
    "/clients/{clientId}/agents/{agentId}/outbound-call": {
      "post": {
        "tags": ["Agents"],
        "summary": "Send Outbound Call",
        "description": "Send an outbound call using the specified agent",
        "parameters": [
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "description": "Client-specific API key for authentication",
            "schema": {
              "type": "string",
              "pattern": "^CD\\.CL\\."
            }
          },
          {
            "name": "clientId",
            "in": "path",
            "required": true,
            "description": "Client ID to initiate the outbound call for",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "agentId",
            "in": "path",
            "required": true,
            "description": "Agent ID to initiate the outbound call with",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "phoneNumberId": {
                    "type": "string",
                    "description": "The phone number ID to use for the call"
                  },
                  "numberToCall": {
                    "type": "string",
                    "description": "The number to call in E.164 format"
                  },
                  "dynamicVariables": {
                    "type": "object"
                  }
                },
                "required": ["phoneNumberId", "numberToCall"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK"
          },
          "500": {
            "description": "Internal Server Error",
            "content": {}
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "PhoneNumber": {
        "type": "object",
        "properties": {
          "_id": {
            "type": "string",
            "description": "The ID of the phone number"
          },
          "clientId": {
            "type": "string",
            "description": "The ID of the client associated with the phone number"
          },
          "platform": {
            "type": "string",
            "description": "The platform this phone number is associated with (Retell/Vapi)"
          },
          "platformId": {
            "type": "string",
            "description": "The ID of the phone number on the platform"
          },
          "apiKey": {
            "type": "string",
            "description": "The platform API key associated with the phone number"
          },
          "number": {
            "type": "string",
            "description": "The phone number in E.164 format"
          },
          "type": {
            "type": "string",
            "description": "The type of phone number (assigned or imported)"
          }
        }
      }
    }
  }
}
