{
  "openapi": "3.0.0",
  "info": {
    "title": "SubVerse API reference",
    "description": "Detailed guide on how to use the SubVerse APIs",
    "license": {
      "name": "MIT"
    },
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "https://api-v2.subverseai.com/api"
    }
  ],
  "security": [
    {
      "ApiKeyAuth": []
    }
  ],
  "paths": {
    "/call/trigger": {
      "post": {
        "description": "Place a call to a customer using your chosen agent and settings.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DirectTriggerCall"
              },
              "examples": {
                "ValidRequest": {
                  "summary": "Example of trigger workflow call",
                  "value": {
                    "phoneNumber": "+912298765432",
                    "metadata": {
                      "email": "johndoe@subverseai.com",
                      "name": "John Doe",
                      "id": "JD75816540"
                    },
                    "agentNumber": "+912298765432",
                    "agentName": "test_case",
                    "agentVersion": "default",
                    "options": {
                      "transcriptLanguage": "hi",
                      "allowedOverallInterruptions": "True",
                      "allowedInterruptionsInitially": "False",
                      "ttsLanguage": "hi",
                      "ttsGender": "male",
                      "voiceId": "IvLWq57RKibBrqZGpQrC",
                      "speed": "2",
                      "transferNumber": "+912298765432",
                      "communicationMethod": "two_way",
                      "dtmfEnabled": "False",
                      "initialMessage": "Hi, ${name} how can I assist you today?",
                      "additionalContext": "The caller is asking about a refund request submitted yesterday."
                    },
                    "noOfRetries": 1,
                    "retryAfterHours": 1,
                    "startWorkingHour": "09:00",
                    "endWorkingHour": "20:00",
                    "timezone": "Asia/Kolkata",
                    "callPriority": 3,
                    "callOnDate": "2025-08-08",
                    "scheduleTime": "2025-08-08T08:14:57Z"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Returns error or success response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiResponse"
                },
                "examples": {
                  "200 success": {
                    "summary": "200 - Call triggered successfully",
                    "value": {
                      "responseCode": 200,
                      "message": "Call triggered successfully",
                      "data": {
                        "callId": "1234"
                      }
                    }
                  },
                  "400 error": {
                    "summary": "400 - Phone number error",
                    "value": {
                      "responseCode": 400,
                      "message": "Phone number is required",
                      "data": null
                    }
                  },
                  "401 error": {
                    "summary": "401 - Api key is missing error",
                    "value": {
                      "responseCode": 401,
                      "message": "Api key is missing",
                      "data": null
                    }
                  },
                  "404 error": {
                    "summary": "404 - Bot number error",
                    "value": {
                      "responseCode": 404,
                      "message": "Bot number is required",
                      "data": null
                    }
                  },
                  "500 error": {
                    "summary": "500 - Internal server error",
                    "value": {
                      "responseCode": 500,
                      "message": "Internal server error",
                      "data": null
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/call/cancel/{callId}": {
      "put": {
        "summary": "Cancel a queued outbound call",
        "description": "Cancels an outbound call that is still queued. Only calls whose call status is `call_in_queue` can be canceled. Removes the pending queued calls and updates call status to canceled.",
        "parameters": [
          {
            "name": "callId",
            "in": "path",
            "description": "unique call identifier",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Call canceled successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiResponse"
                },
                "examples": {
                  "200 success": {
                    "summary": "200 - Call canceled successfully",
                    "value": {
                      "responseCode": 200,
                      "message": "Call canceled successfully!",
                      "data": {
                        "removedJobs": 1
                      }
                    }
                  },
                  "400 missing-call-id": {
                    "summary": "400 - Call ID missing",
                    "value": {
                      "responseCode": 400,
                      "message": "Call id missing",
                      "data": null
                    }
                  },
                  "400 call-not-found": {
                    "summary": "400 - Call does not exist for this company",
                    "value": {
                      "responseCode": 400,
                      "message": "User call not found.",
                      "data": null
                    }
                  },
                  "400 not-in-queue": {
                    "summary": "400 - Call cannot be canceled anymore",
                    "value": {
                      "responseCode": 400,
                      "message": "This call cannot be canceled as it is no longer in queue.",
                      "data": null
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/call/signed-recording-url": {
      "get": {
        "summary": "Generate a secure, time-limited signed URL for a SubVerse private asset",
        "description": "Generates a secure, time-limited pre-signed URL for an asset stored in the SubVerse private S3 bucket, such as call recordings or session attachments. You must provide either 'callId' or 'callRecordingUrl' in the query parameters.",
        "operationId": "getSignedRecordingUrl",
        "parameters": [
          {
            "name": "callId",
            "in": "query",
            "description": "Unique identifier for the call.",
            "required": false,
            "schema": {
              "type": "string",
              "example": "12345"
            }
          },
          {
            "name": "callRecordingUrl",
            "in": "query",
            "description": "A direct S3/Storage URL to a SubVerse private asset (e.g., a call recording, session attachment, etc.).",
            "required": false,
            "schema": {
              "type": "string",
              "example": "https://s3.amazonaws.com/bucket/recording.mp3"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Returns error or success Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiResponse"
                },
                "examples": {
                  "success": {
                    "summary": "200 - Success response",
                    "value": {
                      "responseCode": 200,
                      "message": "Signed url generated successfully!",
                      "data": {
                        "url": "https://example.com/recording.mp3?token=..."
                      }
                    }
                  },
                  "apiMissing": {
                    "summary": "401 - Unauthorized (API key is missing).",
                    "value": {
                      "responseCode": 401,
                      "message": "API key missing!",
                      "data": null
                    }
                  },
                  "callIdRequiredError": {
                    "summary": "400 - Validation error (Missing required parameters).",
                    "value": {
                      "responseCode": 400,
                      "message": "Validation error: Either callId or callRecordingUrl is required",
                      "data": null
                    }
                  },
                  "callNotFound": {
                    "summary": "404 - Call record not found.",
                    "value": {
                      "responseCode": 404,
                      "message": "No call record found, Please contact administrator.",
                      "data": null
                    }
                  },
                  "internalServerError": {
                    "summary": "500 - Internal server error",
                    "value": {
                      "responseCode": 500,
                      "message": "Internal server error!",
                      "data": null
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "tags": [
          "Call"
        ]
      }
    },
    "/session/fetch/{sessionId}": {
      "get": {
        "summary": "Get session details",
        "description": "Get everything about a single session in one place — who was involved, what was said, how it went, and when it happened. For phone calls, you'll also see the call duration, retry info, and a link to the recording.",
        "operationId": "getSessionDetails",
        "tags": [
          "Session"
        ],
        "parameters": [
          {
            "name": "sessionId",
            "in": "path",
            "description": "The unique identifier of the session.",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "example": "sess_01H8XK3Q9V1YJZ5T7N2A8B9C0D"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Session details found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SessionDetailsResponse"
                },
                "examples": {
                  "200 success": {
                    "summary": "200 - Session details found",
                    "value": {
                      "responseCode": 200,
                      "message": "Session details found",
                      "data": {
                        "sessionId": "sess_01H8XK3Q9V1YJZ5T7N2A8B9C0D",
                        "agentDetails": {
                          "name": "SupportBot",
                          "number": "+15551234567",
                          "email": "agent@example.com",
                          "version": "v1.2.0"
                        },
                        "userDetails": {
                          "id": "u_42",
                          "name": "Jane Doe",
                          "number": "+15557654321",
                          "email": "jane@example.com"
                        },
                        "dynamicVariables": {
                          "plan": "pro",
                          "accountId": "acc_99"
                        },
                        "communicationChannelType": "inboundSipTrunk",
                        "communicationChannelName": "Inbound Support Line",
                        "transcript": [
                          {
                            "type": "message",
                            "role": "user",
                            "content": [
                              {
                                "type": "text",
                                "text": "Hi, I want to check my refund."
                              }
                            ],
                            "senderId": "+15557654321",
                            "senderName": "Jane Doe",
                            "agentName": "SupportBot",
                            "metadata": {},
                            "timestamp": "2026-09-07T10:00:00.000Z"
                          },
                          {
                            "type": "function_call",
                            "name": "lookupRefund",
                            "call_id": "call_abc",
                            "arguments": {
                              "accountId": "acc_99"
                            },
                            "phase": "during",
                            "timestamp": "2026-09-07T10:00:03.000Z"
                          },
                          {
                            "type": "function_call_output",
                            "name": "lookupRefund",
                            "call_id": "call_abc",
                            "output": "{\"status\":\"processing\"}",
                            "is_error": false,
                            "executionTimeMs": 340,
                            "phase": "during",
                            "timestamp": "2026-09-07T10:00:03.340Z"
                          },
                          {
                            "type": "thinking",
                            "thinking": "The user is asking about a refund. I should look up their account first.",
                            "timestamp": "2026-09-07T10:00:02.500Z"
                          },
                          {
                            "type": "summary",
                            "summary": "User asked about refund status, agent confirmed processing.",
                            "timestamp": "2026-09-07T10:01:00.000Z"
                          }
                        ],
                        "analysis": {
                          "summary": "User asked about refund status; agent confirmed processing.",
                          "sentiment": "positive"
                        },
                        "status": "call_hangup",
                        "time": "2026-09-07T10:00:00.000Z",
                        "createdAt": "2026-09-07T10:00:00.000Z",
                        "updatedAt": "2026-09-07T10:03:04.000Z",
                        "duration": 184,
                        "retryAttemptNo": 0,
                        "recordingUrl": "https://s3.example.com/signed/recordings/sess_...wav?sig=..."
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - API key is missing or invalid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiResponse"
                },
                "examples": {
                  "apiKeyMissing": {
                    "summary": "401 - API key missing",
                    "value": {
                      "responseCode": 401,
                      "errorCode": "apiKeyMissing",
                      "message": "API key missing",
                      "data": null
                    }
                  },
                  "apiKeyInvalid": {
                    "summary": "401 - Invalid API key",
                    "value": {
                      "responseCode": 401,
                      "errorCode": "apiKeyInvalid",
                      "message": "Invalid API key",
                      "data": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Session not found - the session ID does not exist in the workspace associated with your API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiResponse"
                },
                "examples": {
                  "sessionNotFound": {
                    "summary": "404 - Session not found",
                    "value": {
                      "responseCode": 404,
                      "errorCode": "sessionNotFound",
                      "message": "Session not found",
                      "data": null
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "Validation error - the sessionId path parameter is missing or empty.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiResponse"
                },
                "examples": {
                  "validationError": {
                    "summary": "422 - Validation error",
                    "value": {
                      "responseCode": 422,
                      "errorCode": "validationError",
                      "message": "Expected string length greater or equal to 1",
                      "data": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiResponse"
                },
                "examples": {
                  "internalError": {
                    "summary": "500 - Internal server error",
                    "value": {
                      "responseCode": 500,
                      "errorCode": "internalError",
                      "message": "Internal server error",
                      "data": null
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/chat-agent/trigger": {
      "post": {
        "summary": "Trigger chat",
        "description": "Start a conversation with a customer over WhatsApp, Web Chat or Email using your chosen agent — or get the agent's reply straight back in the response.",
        "operationId": "triggerChat",
        "tags": [
          "Chat"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TriggerChat"
              },
              "examples": {
                "WhatsAppPrompt": {
                  "summary": "WhatsApp — agent writes the message",
                  "value": {
                    "communicationChannel": "Support WhatsApp",
                    "customerNumber": "+919876543210",
                    "agentName": "payment_reminder",
                    "metadata": {
                      "name": "John Doe",
                      "amountDue": "₹1,200"
                    },
                    "whatsappOptions": {
                      "messageType": "prompt",
                      "additionalContext": "Remind the customer that their payment is due tomorrow."
                    }
                  }
                },
                "WhatsAppTemplate": {
                  "summary": "WhatsApp — send an approved template",
                  "value": {
                    "communicationChannel": "Support WhatsApp",
                    "customerNumber": "+919876543210",
                    "whatsappOptions": {
                      "messageType": "template",
                      "templateId": "order_update",
                      "templateLanguage": "en",
                      "templateVariables": {
                        "1": "John",
                        "2": "ORD-1042"
                      }
                    }
                  }
                },
                "EmailSay": {
                  "summary": "Email — send your own text",
                  "value": {
                    "communicationChannel": "Support Email",
                    "customerEmail": "john@example.com",
                    "emailOptions": {
                      "messageType": "say",
                      "subject": "Your order has shipped",
                      "body": "Hi John, your order ORD-1042 is on its way!"
                    }
                  }
                },
                "Scheduled": {
                  "summary": "Scheduled within working hours",
                  "value": {
                    "communicationChannel": "Support WhatsApp",
                    "customerNumber": "+919876543210",
                    "whatsappOptions": {
                      "messageType": "say",
                      "message": "Hi John, just checking in on your recent order."
                    },
                    "scheduleTime": "2026-10-05T04:00:00Z",
                    "startWorkingHour": "09:00",
                    "endWorkingHour": "20:00",
                    "timezone": "Asia/Kolkata"
                  }
                },
                "InstantReply": {
                  "summary": "Get the agent's reply in the response",
                  "value": {
                    "agentName": "support_bot",
                    "doReturnResponse": true,
                    "message": "Where is my order?",
                    "customerEmail": "john@example.com",
                    "metadata": {
                      "orderId": "ORD-1042"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Chat triggered",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiResponse"
                },
                "examples": {
                  "200 sent": {
                    "summary": "200 - Message sent or scheduled",
                    "value": {
                      "responseCode": 200,
                      "message": "Trigger dispatched",
                      "data": {
                        "sessionId": "a3f1c9e2-7b4d-4e8a-9c21-5d6e7f8a9b0c"
                      }
                    }
                  },
                  "200 instant-reply": {
                    "summary": "200 - Agent reply returned (doReturnResponse)",
                    "value": {
                      "responseCode": 200,
                      "message": "Trigger dispatched",
                      "data": {
                        "sessionId": "b7e2d4f1-1c3a-4b5d-8e6f-0a9b8c7d6e5f",
                        "transcript": [
                          {
                            "type": "message",
                            "role": "user",
                            "content": [
                              {
                                "type": "text",
                                "text": "Where is my order?"
                              }
                            ],
                            "senderId": "john@example.com",
                            "timestamp": "2026-10-01T10:00:00.000Z"
                          },
                          {
                            "type": "message",
                            "role": "assistant",
                            "content": [
                              {
                                "type": "text",
                                "text": "Hi! Your order ORD-1042 has shipped and should arrive by Friday."
                              }
                            ],
                            "agentName": "support_bot",
                            "timestamp": "2026-10-01T10:00:02.000Z"
                          }
                        ]
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Something in the request is missing or not allowed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiResponse"
                },
                "examples": {
                  "customerNumberRequired": {
                    "summary": "400 - Customer number missing",
                    "value": {
                      "responseCode": 400,
                      "errorCode": "customerNumberRequired",
                      "message": "customerNumber is required for chat channels",
                      "data": null
                    }
                  },
                  "customerEmailRequired": {
                    "summary": "400 - Customer email missing",
                    "value": {
                      "responseCode": 400,
                      "errorCode": "customerEmailRequired",
                      "message": "customerEmail is required for Email channels",
                      "data": null
                    }
                  },
                  "templateIdRequired": {
                    "summary": "400 - Template name missing",
                    "value": {
                      "responseCode": 400,
                      "errorCode": "templateIdRequired",
                      "message": "whatsappOptions.templateId is required for template message type",
                      "data": null
                    }
                  },
                  "incompatibleOptions": {
                    "summary": "400 - Instant reply used with scheduling",
                    "value": {
                      "responseCode": 400,
                      "errorCode": "incompatibleOptions",
                      "message": "doReturnResponse cannot be used with scheduleTime, startWorkingHour, or endWorkingHour",
                      "data": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "API key missing or invalid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiResponse"
                },
                "examples": {
                  "apiKeyMissing": {
                    "summary": "401 - API key missing",
                    "value": {
                      "responseCode": 401,
                      "errorCode": "apiKeyMissing",
                      "message": "API key missing",
                      "data": null
                    }
                  },
                  "apiKeyInvalid": {
                    "summary": "401 - Invalid API key",
                    "value": {
                      "responseCode": 401,
                      "errorCode": "apiKeyInvalid",
                      "message": "Invalid API key",
                      "data": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Channel or conversation not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiResponse"
                },
                "examples": {
                  "channelNotFound": {
                    "summary": "404 - Channel not found",
                    "value": {
                      "responseCode": 404,
                      "errorCode": "channelNotFound",
                      "message": "Channel 'Support WhatsApp' not found or disabled",
                      "data": null
                    }
                  },
                  "sessionNotFound": {
                    "summary": "404 - Conversation not found",
                    "value": {
                      "responseCode": 404,
                      "errorCode": "sessionNotFound",
                      "message": "Session not found",
                      "data": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Something went wrong on our side",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiResponse"
                },
                "examples": {
                  "internalError": {
                    "summary": "500 - Internal server error",
                    "value": {
                      "responseCode": 500,
                      "errorCode": "internalError",
                      "message": "Internal server error",
                      "data": null
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/chat-agent/cancel/{sessionId}": {
      "delete": {
        "summary": "Cancel scheduled messages",
        "description": "Cancel messages scheduled with Trigger Chat that have not been sent yet.",
        "operationId": "cancelScheduledChat",
        "tags": [
          "Chat"
        ],
        "parameters": [
          {
            "name": "sessionId",
            "in": "path",
            "required": true,
            "description": "The `sessionId` returned by Trigger Chat when the message was scheduled.",
            "schema": {
              "type": "string",
              "example": "a3f1c9e2-7b4d-4e8a-9c21-5d6e7f8a9b0c"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Cancellation result",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiResponse"
                },
                "examples": {
                  "cancelled": {
                    "summary": "200 - Scheduled messages cancelled",
                    "value": {
                      "responseCode": 200,
                      "message": "Scheduled messages cancelled successfully",
                      "data": {
                        "sessionId": "a3f1c9e2-7b4d-4e8a-9c21-5d6e7f8a9b0c",
                        "isCancelled": true
                      }
                    }
                  },
                  "nothing": {
                    "summary": "200 - Nothing scheduled",
                    "value": {
                      "responseCode": 200,
                      "message": "No scheduled jobs found",
                      "data": {
                        "sessionId": "a3f1c9e2-7b4d-4e8a-9c21-5d6e7f8a9b0c",
                        "isCancelled": false,
                        "reason": "No scheduled jobs found for this session"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "API key missing or invalid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiResponse"
                },
                "examples": {
                  "apiKeyMissing": {
                    "summary": "401 - API key missing",
                    "value": {
                      "responseCode": 401,
                      "errorCode": "apiKeyMissing",
                      "message": "API key missing",
                      "data": null
                    }
                  },
                  "apiKeyInvalid": {
                    "summary": "401 - Invalid API key",
                    "value": {
                      "responseCode": 401,
                      "errorCode": "apiKeyInvalid",
                      "message": "Invalid API key",
                      "data": null
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "DirectTriggerCall": {
        "type": "object",
        "required": [
          "phoneNumber",
          "agentName"
        ],
        "properties": {
          "phoneNumber": {
            "type": "string",
            "description": "User's phone number. Must be a valid phone number with country code, with or without '+' prefix."
          },
          "agentName": {
            "type": "string",
            "description": "Agent to be used for the call, find it in Agents sections in dashboard."
          },
          "agentVersion": {
            "$ref": "#/components/schemas/AgentVersion"
          },
          "metadata": {
            "type": "object",
            "description": "Customer's details to be used in the call, use them in agent initial and system prompt as ${variable_name} format. These will be replaced by actual value of the variables."
          },
          "channel": {
            "type": "string",
            "description": "Channel to be used for the call (SIP Outbound). If provided, number will be randomly picked from the configured channel."
          },
          "agentNumber": {
            "type": "string",
            "description": "Agent phone number used to place call. Default value will be any number set in communication channel section (SIP Outbound). Must be a valid phone number with country code, with or without '+' prefix."
          },
          "options": {
            "type": "object",
            "description": "Default values as defined in the Agents section in dashboard. Use this if you want to override those options. E.g. if you want to change the language, voice, initial prompt, etc.",
            "$ref": "#/components/schemas/VoiceAgentOptions"
          },
          "noOfRetries": {
            "type": "number",
            "description": "Number of retries if call failed if provided"
          },
          "retryAfterHours": {
            "type": "number",
            "description": "Retry at interval (in hrs) if provided"
          },
          "startWorkingHour": {
            "type": "string",
            "description": "24 hour format (HH:MM). If provided call made before start hours will rescheduled at start hour of the day."
          },
          "endWorkingHour": {
            "type": "string",
            "description": "24 hour format (HH:MM). If provided call made after end hours will rescheduled at start hour of next day."
          },
          "timezone": {
            "type": "string",
            "description": "Call between start working hour and end working hour in timezone if provided [Default: Asia/Kolkata]"
          },
          "callPriority": {
            "type": "number",
            "description": "Defines the urgency of the call on a scale of 1 to 100, where 1 is the highest priority and 100 is the lowest. Default is 10."
          },
          "callOnDate": {
            "type": "string",
            "description": "The date by which the call must be placed. If the call is not made on same day, it is marked as expired and will not trigger. Any valid date format is Any valid date format is “YYYY-MM-DD”."
          },
          "scheduleTime": {
            "type": "string",
            "description": "Schedule customer's call at a specific future time. Follow ISO date format (YYYY-MM-DDTHH:MM:SSZ)."
          }
        }
      },
      "WorkflowTriggerCall": {
        "type": "object",
        "required": [
          "customer_number"
        ],
        "properties": {
          "customer_number": {
            "type": "string",
            "description": "User's phone number. Must be a valid phone number with country code, with or without '+' prefix."
          },
          "customer_details": {
            "type": "object",
            "description": "User's details to be used in the call, use them in agent initial and system prompt as ${variable_name} format. These will be replaced by actual value of the variables."
          },
          "use_case": {
            "type": "string",
            "description": "Agent to be used for the call, find it in Agents sections in dashboard. Default value: agent selected in the workflow."
          },
          "agent_version": {
            "$ref": "#/components/schemas/AgentVersion"
          },
          "bot_number": {
            "type": "string",
            "description": "Voice agent phone number used to place call. Must be a valid phone number with country code, with or without '+' prefix. Default value: bot number selected in the workflow."
          },
          "schedule_time": {
            "type": "string",
            "description": "Schedule customer's call at a specific future time. Follow ISO date format (YYYY-MM-DDTHH:MM:SSZ). Default value: current time, to trigger the call immediately."
          },
          "options": {
            "type": "object",
            "description": "Default values as defined in the Agents section in dashboard. Use this if you want to override those options. E.g. if you want to change the language, voice, initial prompt, etc.",
            "$ref": "#/components/schemas/VoiceAgentOptions"
          },
          "no_of_retries": {
            "type": "number",
            "description": "Number of retries if call failed if provided"
          },
          "retry_after_in_hrs": {
            "type": "number",
            "description": "Retry at interval (in hrs) if provided"
          },
          "start_working_hour": {
            "type": "string",
            "description": "24 hour format (HH:MM). If provided call made before start hours will rescheduled at start hour of the day."
          },
          "end_working_hour": {
            "type": "string",
            "description": "24 hour format (HH:MM). If provided call made after end hours will rescheduled at start hour of next day."
          },
          "timezone": {
            "type": "string",
            "description": "Call between start working hour and end working hour in timezone if provided [Default: Asia/Kolkata]"
          },
          "call_priority": {
            "type": "number",
            "description": "Defines the urgency of the call on a scale of 1 to 100, where 1 is the highest priority and 100 is the lowest. Default is 10."
          },
          "call_on_date": {
            "type": "string",
            "description": "The date by which the call must be placed. If the call is not made on same day, it is marked as expired and will not trigger. Any valid date format is “YYYY-MM-DD”"
          }
        }
      },
      "VoiceAgentOptions": {
        "type": "object",
        "properties": {
          "transcriptLanguage": {
            "type": "string",
            "description": "The language used to capture and understand what the user says.",
            "enum": [
              "en-IN",
              "hi"
            ]
          },
          "ttsLanguage": {
            "type": "string",
            "description": "Default language of the voice agent used to speak with the user.",
            "enum": [
              "en",
              "hi"
            ],
            "example": "en"
          },
          "ttsGender": {
            "type": "string",
            "description": "The gender of the voice agent used to speak with the user.",
            "enum": [
              "male",
              "female"
            ]
          },
          "voiceId": {
            "type": "string",
            "description": "The specific voice if that the voice agent will use. You can also provide custom voice id other than the ones mentioned here. Recommended list of Indian voices below: \n M LEO ENG - 'TNHbwIMY5QmLqZdvjhNn'\n F MONIKA ENG - '2zRM7PkgwBPiau2jvVXc'\n F RIYA ENG - 'vYENaCJHl4vFKNDYPr8y'\n M LEO BOTH - 'IvLWq57RKibBrqZGpQrC'\n F MONIKA BOTH - '1qEiC6qsybMkmnNdVMbK'\n F RIYA BOTH - 'mActWQg9kibLro6Z2ouY'",
            "enum": [
              "TNHbwIMY5QmLqZdvjhNn",
              "2zRM7PkgwBPiau2jvVXc",
              "vYENaCJHl4vFKNDYPr8y",
              "IvLWq57RKibBrqZGpQrC",
              "1qEiC6qsybMkmnNdVMbK",
              "mActWQg9kibLro6Z2ouY",
              "mention any other custom voice id"
            ]
          },
          "initialMessage": {
            "type": "string",
            "description": "The initial greetings message. The dynamic variables (e.g. ${name}) will be replaced by actual value provided in customer_details or metadata."
          },
          "additionalContext": {
            "type": "string",
            "description": "Extra context provided to the voice agent (e.g. details that are unique to the target customer category, which is not mentioned in the system prompt). The dynamic variables (e.g. ${name}) will be replaced by actual value provided in customer_details or metadata."
          },
          "allowedOverallInterruptions": {
            "type": "string",
            "description": "Whether the voice agent should stop speaking upon user interruption during the entire conversation.",
            "enum": [
              "True",
              "False"
            ]
          },
          "allowedInterruptionsInitially": {
            "type": "string",
            "description": "Whether the voice agent should stop speaking upon user interruption while initial greetings message is playing.",
            "enum": [
              "True",
              "False"
            ]
          },
          "speed": {
            "type": "string",
            "description": "How fast or slow the voice agent should talk.",
            "enum": [
              "0",
              "1",
              "2",
              "3"
            ]
          },
          "transferNumber": {
            "type": "string",
            "description": "Human agent's phone number to transfer the call in case of escalations. Must be a valid phone number with country code, with or without '+' prefix."
          },
          "communicationMethod": {
            "type": "string",
            "description": "Whether the communication is two-way (inetractive conversation) or one-way (speak only the initial prompt and hang up).",
            "enum": [
              "two_way",
              "one_way"
            ]
          },
          "dtmfEnabled": {
            "type": "string",
            "description": "Whether the user can press buttons on their phone (like 'Press 1 for support') to interact with the agent.",
            "enum": [
              "True",
              "False"
            ]
          }
        }
      },
      "ApiResponse": {
        "type": "object",
        "required": [
          "responseCode",
          "message"
        ],
        "properties": {
          "responseCode": {
            "type": "integer",
            "description": "Always returns 200 value, with error or success response details in message."
          },
          "message": {
            "type": "string",
            "description": "Success or error message with description."
          },
          "data": {
            "nullable": true,
            "description": "Additional details if available."
          }
        }
      },
      "Error": {
        "required": [
          "error",
          "message"
        ],
        "type": "object",
        "properties": {
          "error": {
            "type": "integer",
            "format": "int32"
          },
          "message": {
            "type": "string"
          }
        }
      },
      "AgentVersion": {
        "oneOf": [
          {
            "type": "integer",
            "minimum": 0,
            "description": "Specific version number of the agent (e.g., 1, 2)."
          },
          {
            "type": "string",
            "enum": [
              "default",
              "draft"
            ],
            "description": "Version tag: 'default' uses the currently published version, 'draft' uses the latest saved draft."
          }
        ],
        "description": "Determines which version of the agent to use for the call. Defaults to \"default\"."
      },
      "AgentBlueprintsResponse": {
        "type": "object",
        "required": [
          "responseCode",
          "message",
          "data"
        ],
        "properties": {
          "responseCode": {
            "type": "integer",
            "description": "HTTP status code indicating the result of the request.",
            "example": 200
          },
          "message": {
            "type": "string",
            "description": "Human-readable message describing the result of the request.",
            "example": "Agent blueprints retrieved successfully!"
          },
          "data": {
            "$ref": "#/components/schemas/AgentBlueprintsData"
          }
        }
      },
      "AgentBlueprintsData": {
        "type": "object",
        "required": [
          "agents",
          "workflowList"
        ],
        "properties": {
          "agents": {
            "type": "array",
            "description": "Array of agent configurations and metadata.",
            "items": {
              "$ref": "#/components/schemas/AgentBlueprint"
            }
          },
          "workflowList": {
            "type": "array",
            "description": "Array of workflow-to-agent mappings showing which workflows use which agents.",
            "items": {
              "$ref": "#/components/schemas/WorkflowMapping"
            }
          }
        }
      },
      "AgentBlueprint": {
        "type": "object",
        "required": [
          "agentId",
          "config",
          "version"
        ],
        "properties": {
          "agentId": {
            "type": "string",
            "description": "The human-readable unique identifier for the agent.",
            "example": "abandoned_checkout"
          },
          "config": {
            "type": "object",
            "description": "Complete configuration object for the agent including LLM, STT, TTS services, instructions, and operational settings.",
            "properties": {
              "llmService": {
                "type": "object",
                "description": "Language model service configuration for the agent.",
                "properties": {
                  "provider": {
                    "type": "string",
                    "description": "The LLM provider (e.g., 'openai', 'google', 'anthropic').",
                    "example": "openai"
                  },
                  "model": {
                    "type": "string",
                    "description": "The specific model to use.",
                    "example": "gpt-4o-mini"
                  },
                  "temperature": {
                    "type": "number",
                    "description": "Controls randomness in responses (0.0-1.0).",
                    "example": 0.5
                  }
                }
              },
              "sttService": {
                "type": "object",
                "description": "Speech-to-text service configuration for understanding user speech.",
                "properties": {
                  "provider": {
                    "type": "string",
                    "description": "The STT provider (e.g., 'deepgram', 'openai').",
                    "example": "deepgram"
                  },
                  "model": {
                    "type": "string",
                    "description": "The specific STT model to use.",
                    "example": "nova-2-general"
                  },
                  "language": {
                    "type": "string",
                    "description": "Language code for speech recognition.",
                    "example": "hi-IN"
                  },
                  "smartFormat": {
                    "type": "boolean",
                    "description": "Whether to enable smart formatting of numbers, dates, etc.",
                    "example": false
                  },
                  "numerals": {
                    "type": "boolean",
                    "description": "Whether to convert numerals to words.",
                    "example": false
                  },
                  "keywords": {
                    "type": "array",
                    "description": "Array of keywords to boost in speech recognition.",
                    "items": {
                      "type": "string"
                    },
                    "nullable": true,
                    "example": null
                  }
                }
              },
              "ttsService": {
                "type": "object",
                "description": "Text-to-speech service configuration for the agent's voice.",
                "properties": {
                  "provider": {
                    "type": "string",
                    "description": "The TTS provider (e.g., 'elevenlabs', 'openai').",
                    "example": "elevenlabs"
                  },
                  "model": {
                    "type": "string",
                    "description": "The specific TTS model to use.",
                    "example": "eleven_flash_v2_5"
                  },
                  "language": {
                    "type": "string",
                    "description": "Language code for the voice.",
                    "example": "en-IN"
                  },
                  "gender": {
                    "type": "string",
                    "description": "Voice gender preference.",
                    "example": "female"
                  },
                  "voiceName": {
                    "type": "string",
                    "description": "Name of the voice to use.",
                    "example": "monika"
                  },
                  "customVoiceId": {
                    "type": "string",
                    "description": "Custom voice ID if using a trained voice.",
                    "example": ""
                  },
                  "speed": {
                    "type": "number",
                    "description": "Speech speed multiplier.",
                    "example": 2
                  },
                  "stability": {
                    "type": "number",
                    "description": "Voice stability setting (0.0-1.0).",
                    "example": 0.5
                  },
                  "similarityBoost": {
                    "type": "number",
                    "description": "Voice similarity boost setting.",
                    "example": 0.8
                  },
                  "pitch": {
                    "type": "number",
                    "description": "Voice pitch setting.",
                    "example": 2
                  },
                  "volume": {
                    "type": "number",
                    "description": "Voice volume setting.",
                    "example": 2
                  }
                }
              },
              "agentInstructions": {
                "type": "object",
                "description": "Instructions and prompts that define the agent's behavior and personality.",
                "properties": {
                  "initialMessage": {
                    "type": "object",
                    "description": "The initial message the agent will say.",
                    "properties": {
                      "messageContent": {
                        "type": "string",
                        "description": "The content of the initial message.",
                        "example": "Hello, I am calling from Testing. How can I help you today?"
                      },
                      "messageType": {
                        "type": "string",
                        "description": "Type of message ('say' or 'prompt').",
                        "example": "say"
                      },
                      "firstSpeaker": {
                        "type": "string",
                        "description": "Who speaks first.",
                        "example": "assistant"
                      }
                    }
                  },
                  "systemContext": {
                    "type": "array",
                    "description": "Array of system context messages defining agent behavior.",
                    "items": {
                      "type": "object",
                      "properties": {
                        "system": {
                          "type": "string",
                          "description": "System instruction or prompt.",
                          "example": "You are a helpful customer support agent."
                        }
                      }
                    }
                  },
                  "conversationalFlow": {
                    "type": "object",
                    "description": "Visual flow configuration for the agent's conversation logic.",
                    "properties": {
                      "nodes": {
                        "type": "array",
                        "description": "Array of conversation flow nodes.",
                        "items": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "description": "Unique identifier for the node.",
                              "example": "begin"
                            },
                            "type": {
                              "type": "string",
                              "description": "Type of node (e.g., 'beginCallNode', 'conversationNode', 'endCallNode').",
                              "example": "beginCallNode"
                            },
                            "data": {
                              "type": "object",
                              "description": "Node-specific data and configuration.",
                              "example": {}
                            }
                          }
                        }
                      },
                      "edges": {
                        "type": "array",
                        "description": "Array of connections between nodes.",
                        "items": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "description": "Unique identifier for the edge.",
                              "example": "edge123"
                            },
                            "source": {
                              "type": "string",
                              "description": "Source node ID.",
                              "example": "begin"
                            },
                            "target": {
                              "type": "string",
                              "description": "Target node ID.",
                              "example": "conversation"
                            }
                          }
                        }
                      }
                    }
                  }
                }
              },
              "callSettings": {
                "type": "object",
                "description": "Call-related settings and configurations.",
                "properties": {
                  "dtmfEnabled": {
                    "type": "boolean",
                    "description": "Whether DTMF (touch-tone) input is enabled.",
                    "example": false
                  },
                  "transferTo": {
                    "type": "string",
                    "description": "Phone number to transfer calls to.",
                    "example": ""
                  },
                  "transferDtmf": {
                    "type": "string",
                    "description": "DTMF sequence for transfer.",
                    "example": ""
                  },
                  "warmTransfer": {
                    "type": "boolean",
                    "description": "Whether warm transfer is enabled.",
                    "example": false
                  },
                  "sipRefer": {
                    "type": "boolean",
                    "description": "Whether SIP refer is enabled.",
                    "example": false
                  },
                  "backgroundAmbient": {
                    "type": "boolean",
                    "description": "Whether background ambient sound is enabled.",
                    "example": false
                  },
                  "backgroundThinking": {
                    "type": "boolean",
                    "description": "Whether background thinking sound is enabled.",
                    "example": false
                  },
                  "whisper": {
                    "type": "boolean",
                    "description": "Whether whisper mode is enabled.",
                    "example": false
                  },
                  "falseInterruptionTimer": {
                    "type": "number",
                    "description": "Timer for false interruption detection in seconds.",
                    "example": 3
                  },
                  "preemptiveGeneration": {
                    "type": "boolean",
                    "description": "Whether preemptive response generation is enabled.",
                    "example": true
                  }
                }
              },
              "pipelineSettings": {
                "type": "object",
                "description": "Pipeline and processing settings.",
                "properties": {
                  "commMethod": {
                    "type": "string",
                    "description": "Communication method ('one_way' or 'two_way').",
                    "example": "two_way"
                  },
                  "silenceTime": {
                    "type": "number",
                    "description": "Silence detection threshold in seconds.",
                    "example": 8
                  },
                  "silenceTurns": {
                    "type": "number",
                    "description": "Number of silent turns before action.",
                    "example": 2
                  },
                  "knowledgeBaseId": {
                    "type": "string",
                    "description": "ID of the knowledge base to use.",
                    "example": ""
                  },
                  "maxDuration": {
                    "type": "number",
                    "description": "Maximum call duration in seconds.",
                    "example": 600
                  }
                }
              },
              "turnManagement": {
                "type": "object",
                "description": "Turn-taking and interruption management settings.",
                "properties": {
                  "interruptionOverall": {
                    "type": "boolean",
                    "description": "Whether interruption is enabled overall.",
                    "example": true
                  },
                  "interruptionInitial": {
                    "type": "boolean",
                    "description": "Whether interruption is enabled for initial message.",
                    "example": false
                  },
                  "interruptionSensitivity": {
                    "type": "number",
                    "description": "Interruption sensitivity level.",
                    "example": 2
                  },
                  "agentResponsiveness": {
                    "type": "number",
                    "description": "Agent responsiveness level.",
                    "example": 4
                  },
                  "agentBackchannel": {
                    "type": "object",
                    "description": "Backchannel response settings.",
                    "properties": {
                      "enabled": {
                        "type": "boolean",
                        "description": "Whether backchannel is enabled.",
                        "example": true
                      },
                      "threshold": {
                        "type": "number",
                        "description": "Backchannel activation threshold.",
                        "example": 0
                      },
                      "fillerWords": {
                        "type": "array",
                        "description": "Array of filler words for backchannel.",
                        "items": {
                          "type": "string"
                        },
                        "example": []
                      },
                      "probability": {
                        "type": "number",
                        "description": "Backchannel response probability.",
                        "example": 1
                      },
                      "interruptions": {
                        "type": "boolean",
                        "description": "Whether backchannel can interrupt.",
                        "example": true
                      },
                      "addToContext": {
                        "type": "boolean",
                        "description": "Whether backchannel is added to context.",
                        "example": false
                      }
                    }
                  }
                }
              },
              "analyticsConfig": {
                "type": "object",
                "description": "Analytics and monitoring configuration.",
                "properties": {
                  "enabled": {
                    "type": "boolean",
                    "description": "Whether analytics is enabled.",
                    "example": true
                  },
                  "provider": {
                    "type": "string",
                    "description": "Analytics provider.",
                    "example": "openai"
                  },
                  "model": {
                    "type": "string",
                    "description": "Analytics model to use.",
                    "example": "gpt-4o-mini"
                  },
                  "instructions": {
                    "type": "string",
                    "description": "Additional analytics instructions.",
                    "nullable": true,
                    "example": null
                  },
                  "queries": {
                    "type": "array",
                    "description": "Analytics queries to run.",
                    "items": {
                      "type": "object",
                      "properties": {
                        "name": {
                          "type": "string",
                          "description": "Query name.",
                          "example": "summary"
                        },
                        "description": {
                          "type": "string",
                          "description": "Query description.",
                          "example": "Summary of discussion between agent and customer."
                        },
                        "type": {
                          "type": "string",
                          "description": "Query type.",
                          "example": "text"
                        },
                        "options": {
                          "type": "array",
                          "description": "Query options.",
                          "items": {},
                          "example": []
                        }
                      }
                    }
                  }
                }
              },
              "functionSettings": {
                "type": "object",
                "description": "Function and tool settings.",
                "properties": {
                  "preCall": {
                    "type": "array",
                    "description": "Functions available before call starts.",
                    "items": {
                      "type": "string"
                    },
                    "example": []
                  },
                  "duringCall": {
                    "type": "array",
                    "description": "Functions available during call.",
                    "items": {
                      "type": "string"
                    },
                    "example": [
                      "end_call",
                      "transfer_call"
                    ]
                  },
                  "postCall": {
                    "type": "array",
                    "description": "Functions available after call ends.",
                    "items": {
                      "type": "string"
                    },
                    "example": []
                  }
                }
              },
              "agentsList": {
                "type": "array",
                "description": "List of agent transfer configurations for this agent.",
                "items": {
                  "type": "object",
                  "description": "Agent transfer configuration.",
                  "properties": {
                    "transferTo": {
                      "type": "string",
                      "description": "Agent ID to transfer to.",
                      "example": "conv_test"
                    },
                    "useBaseSettings": {
                      "type": "boolean",
                      "description": "Whether to use base settings for transfer.",
                      "example": true
                    },
                    "agentVersion": {
                      "type": "string",
                      "description": "Version of the agent to transfer to.",
                      "example": "default"
                    }
                  }
                },
                "example": []
              },
              "dynamicVariablesConfig": {
                "type": "array",
                "description": "Configuration for dynamic variables that can be used in agent prompts.",
                "items": {
                  "type": "object",
                  "description": "Dynamic variable configuration.",
                  "properties": {
                    "name": {
                      "type": "string",
                      "description": "Variable name.",
                      "example": "customer_name"
                    },
                    "type": {
                      "type": "string",
                      "description": "Variable type.",
                      "example": "string"
                    },
                    "description": {
                      "type": "string",
                      "description": "Variable description.",
                      "example": "Customer's name for personalization"
                    }
                  }
                },
                "example": []
              }
            }
          },
          "version": {
            "$ref": "#/components/schemas/AgentVersionInfo"
          }
        }
      },
      "AgentVersionInfo": {
        "type": "object",
        "required": [
          "name",
          "number"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "Human-readable name for this version of the agent.",
            "example": "v0"
          },
          "description": {
            "type": "string",
            "description": "Detailed description of this version's purpose or changes.",
            "example": "First version"
          },
          "number": {
            "type": "integer",
            "description": "Version number for this agent configuration.",
            "example": 0
          }
        }
      },
      "WorkflowMapping": {
        "type": "object",
        "required": [
          "workflowId",
          "agentId"
        ],
        "properties": {
          "workflowId": {
            "type": "string",
            "description": "Unique identifier for the workflow.",
            "example": "inbound_support"
          },
          "agentId": {
            "type": "string",
            "description": "ID of the agent assigned to this workflow.",
            "example": "SupportBot"
          }
        }
      },
      "SessionDetailsResponse": {
        "type": "object",
        "required": [
          "responseCode",
          "message",
          "data"
        ],
        "properties": {
          "responseCode": {
            "type": "integer",
            "description": "HTTP status code indicating the result of the request.",
            "example": 200
          },
          "message": {
            "type": "string",
            "description": "Human-readable message describing the result of the request.",
            "example": "Session details found"
          },
          "data": {
            "$ref": "#/components/schemas/SessionDetails"
          }
        }
      },
      "SessionDetails": {
        "type": "object",
        "required": [
          "sessionId",
          "agentDetails",
          "userDetails",
          "communicationChannelType",
          "transcript",
          "status",
          "time",
          "createdAt",
          "updatedAt"
        ],
        "properties": {
          "sessionId": {
            "type": "string",
            "description": "Unique session identifier.",
            "example": "sess_01H8XK3Q9V1YJZ5T7N2A8B9C0D"
          },
          "agentDetails": {
            "$ref": "#/components/schemas/SessionAgentDetails"
          },
          "userDetails": {
            "$ref": "#/components/schemas/SessionUserDetails"
          },
          "dynamicVariables": {
            "type": "object",
            "nullable": true,
            "description": "Custom variables associated with the session.",
            "example": {
              "plan": "pro",
              "accountId": "acc_99"
            }
          },
          "communicationChannelType": {
            "type": "string",
            "description": "The channel type used for the session.",
            "enum": [
              "email",
              "inboundSipTrunk",
              "outboundSipTrunk",
              "waChat",
              "waVoice",
              "sms",
              "webChat"
            ],
            "example": "inboundSipTrunk"
          },
          "communicationChannelName": {
            "type": "string",
            "nullable": true,
            "description": "Human-readable name of the channel.",
            "example": "Inbound Support Line"
          },
          "transcript": {
            "type": "array",
            "description": "Full conversation transcript in chronological order. Each entry has a `type` field that determines its structure (message, function_call, function_call_output, thinking, or summary).",
            "items": {
              "type": "object"
            }
          },
          "analysis": {
            "type": "object",
            "nullable": true,
            "description": "AI-generated post-session analysis (summary, sentiment, tags, etc.). Content depends on your agent's analytics configuration.",
            "example": {
              "summary": "User asked about refund status; agent confirmed processing.",
              "sentiment": "positive"
            }
          },
          "status": {
            "type": "string",
            "description": "Current session status.",
            "enum": [
              "active",
              "completed",
              "call_in_queue",
              "call_placed",
              "call_in_progress",
              "call_errored",
              "call_expired",
              "call_hangup",
              "agent_errored",
              "call_canceled",
              "could_not_connect"
            ],
            "example": "call_hangup"
          },
          "time": {
            "type": "string",
            "format": "date-time",
            "description": "When the session started (ISO 8601).",
            "example": "2026-09-07T10:00:00.000Z"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "description": "When the session record was created (ISO 8601).",
            "example": "2026-09-07T10:00:00.000Z"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "description": "When the session record was last updated (ISO 8601).",
            "example": "2026-09-07T10:03:04.000Z"
          },
          "duration": {
            "type": "number",
            "nullable": true,
            "description": "Session duration in seconds. Only present for call sessions (SIP trunk channels).",
            "example": 184
          },
          "retryAttemptNo": {
            "type": "number",
            "nullable": true,
            "description": "Retry attempt number (0 = original, 1+ = retry). Only present for call sessions.",
            "example": 0
          },
          "recordingUrl": {
            "type": "string",
            "nullable": true,
            "description": "Signed URL to the call recording (expires after a limited time). Only present for call sessions.",
            "example": "https://s3.example.com/signed/recordings/sess_...wav?sig=..."
          }
        }
      },
      "SessionAgentDetails": {
        "type": "object",
        "required": [
          "name"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "Agent name.",
            "example": "SupportBot"
          },
          "number": {
            "type": "string",
            "nullable": true,
            "description": "Agent phone number (if applicable).",
            "example": "+15551234567"
          },
          "email": {
            "type": "string",
            "nullable": true,
            "description": "Agent email address (if applicable).",
            "example": "agent@example.com"
          },
          "version": {
            "type": "string",
            "nullable": true,
            "description": "Agent version label.",
            "example": "v1.2.0"
          }
        }
      },
      "SessionUserDetails": {
        "type": "object",
        "required": [
          "id"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "User identifier (phone number, email, or custom ID).",
            "example": "u_42"
          },
          "name": {
            "type": "string",
            "nullable": true,
            "description": "User display name.",
            "example": "Jane Doe"
          },
          "number": {
            "type": "string",
            "nullable": true,
            "description": "User phone number.",
            "example": "+15557654321"
          },
          "email": {
            "type": "string",
            "nullable": true,
            "description": "User email address.",
            "example": "jane@example.com"
          }
        }
      },
      "TriggerChat": {
        "type": "object",
        "properties": {
          "communicationChannel": {
            "type": "string",
            "description": "Name of the WhatsApp, Web Chat or Email channel to send from, exactly as it appears under Integrations in your dashboard. Leave it out when using `doReturnResponse`.",
            "example": "Support WhatsApp"
          },
          "customerNumber": {
            "type": "string",
            "description": "Who to message. For WhatsApp, the customer's phone number with country code (e.g. `+919876543210`). For Web Chat, the user's ID on your website or app. Required for WhatsApp and Web Chat channels."
          },
          "customerEmail": {
            "type": "string",
            "format": "email",
            "description": "The customer's email address. Required for Email channels."
          },
          "agentName": {
            "type": "string",
            "description": "The agent that should handle the conversation. If left out, the agent assigned to the channel is used. Required when `doReturnResponse` is `true`."
          },
          "agentVersion": {
            "type": "string",
            "description": "Which version of the agent to use: `default` (the published version), `draft` (latest saved draft) or a version number such as `2`. If left out, the channel's version (or the published version) is used."
          },
          "agentNumber": {
            "type": "string",
            "description": "WhatsApp only. The business number to send from. It must be one of the numbers on the selected channel. If left out, one of the channel's numbers is picked for you."
          },
          "metadata": {
            "type": "object",
            "additionalProperties": true,
            "description": "Details about the customer to personalise the conversation. Use them in your agent's prompts as `${variable_name}` and they will be replaced with the real values.",
            "example": {
              "name": "John Doe",
              "orderId": "ORD-1042"
            }
          },
          "whatsappOptions": {
            "$ref": "#/components/schemas/WhatsAppOptions"
          },
          "emailOptions": {
            "$ref": "#/components/schemas/EmailOptions"
          },
          "attachments": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uri"
            },
            "description": "Links to files (images, PDFs, documents, etc.) to send along with the message. Links must be publicly accessible."
          },
          "scheduleTime": {
            "type": "string",
            "format": "date-time",
            "description": "Send the message at a future date and time (ISO format, e.g. `2026-10-05T09:30:00Z`). If the time has already passed, the message is sent right away."
          },
          "startWorkingHour": {
            "type": "string",
            "description": "Earliest time of day to send, in 24-hour `HH:MM` format. Messages due before this time wait until it is reached.",
            "example": "09:00"
          },
          "endWorkingHour": {
            "type": "string",
            "description": "Latest time of day to send, in 24-hour `HH:MM` format. Messages due later are sent the next day at `startWorkingHour` (or at midnight if `startWorkingHour` isn't set).",
            "example": "20:00"
          },
          "timezone": {
            "type": "string",
            "description": "Timezone used for `startWorkingHour` and `endWorkingHour`, e.g. `Asia/Kolkata` or `America/New_York`. Defaults to `UTC`."
          },
          "doReturnResponse": {
            "type": "boolean",
            "default": false,
            "description": "Set to `true` to get the agent's reply straight back in the API response instead of sending it to a customer. Useful for testing an agent or building your own chat experience. Cannot be combined with scheduling options."
          },
          "message": {
            "type": "string",
            "description": "Used with `doReturnResponse`. The customer's message for the agent to reply to."
          },
          "sessionId": {
            "type": "string",
            "description": "Used with `doReturnResponse`. The `sessionId` from an earlier response, to continue the same conversation. Leave it out to start a new one."
          },
          "chatOptions": {
            "type": "object",
            "description": "Used with `doReturnResponse`.",
            "properties": {
              "additionalContext": {
                "type": "string",
                "description": "Extra instructions or background for the agent for this reply only."
              }
            }
          }
        }
      },
      "WhatsAppOptions": {
        "type": "object",
        "description": "Options for WhatsApp channels. For Web Chat channels, only `additionalContext` applies.",
        "properties": {
          "messageType": {
            "type": "string",
            "enum": [
              "prompt",
              "say",
              "template"
            ],
            "default": "prompt",
            "description": "How the first message is created. `prompt`: the agent writes the message. `say`: send your exact text from `message`. `template`: send an approved WhatsApp template."
          },
          "additionalContext": {
            "type": "string",
            "description": "With `prompt`: extra instructions or background the agent should use when writing the message, e.g. \"Remind the customer their payment is due tomorrow.\""
          },
          "message": {
            "type": "string",
            "description": "With `say`: the exact text to send. Required for `say`."
          },
          "templateId": {
            "type": "string",
            "description": "With `template`: the name of your approved WhatsApp template. Required for `template`."
          },
          "templateLanguage": {
            "type": "string",
            "default": "en",
            "description": "With `template`: the template's language code, e.g. `en` or `hi`."
          },
          "templateVariables": {
            "type": "object",
            "additionalProperties": true,
            "description": "With `template`: values to fill into the template's placeholders.",
            "example": {
              "1": "John",
              "2": "ORD-1042"
            }
          }
        }
      },
      "EmailOptions": {
        "type": "object",
        "description": "Options for Email channels.",
        "properties": {
          "messageType": {
            "type": "string",
            "enum": [
              "prompt",
              "say"
            ],
            "default": "prompt",
            "description": "`prompt`: the agent writes the email. `say`: send your exact text from `body`."
          },
          "additionalContext": {
            "type": "string",
            "description": "With `prompt`: extra instructions or background the agent should use when writing the email."
          },
          "body": {
            "type": "string",
            "description": "With `say`: the exact email content to send. Required for `say`."
          },
          "subject": {
            "type": "string",
            "description": "Email subject line."
          },
          "cc": {
            "type": "string",
            "description": "Email addresses to CC, separated by commas."
          },
          "bcc": {
            "type": "string",
            "description": "Email addresses to BCC, separated by commas."
          },
          "replyTo": {
            "type": "string",
            "description": "The `sessionId` of an earlier email conversation. The email is sent as a reply in that same thread, keeping anyone previously in CC/BCC. Leave it out to start a new email thread."
          }
        }
      }
    },
    "securitySchemes": {
      "ApiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "x-api-key",
        "description": "Authentication header containing API key from SubVerse dashboard."
      }
    }
  }
}
