{
  "openapi": "3.0.1",
  "info": {
    "title": "ChatDash API Documentation",
    "description": "API Documentation for the ChatDash Server",
    "version": "2.0.0"
  },
  "servers": [
    {
      "url": "https://api.chat-dash.com/v1/public"
    }
  ],
  "paths": {
    "/agents/{agentId}/conversations/{conversationId}/messages": {
      "get": {
        "tags": ["Messages"],
        "summary": "Get Conversation Messages",
        "description": "Get all messages for a conversation",
        "parameters": [
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "description": "All requests to the ChatDash API must be validated with the agency API Key found on your agency profile",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "agentId",
            "in": "path",
            "required": true,
            "description": "The ID of the agent",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "conversationId",
            "in": "path",
            "required": true,
            "description": "The ID of the conversation",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "oneOf": [
                      {
                        "$ref": "#/components/schemas/TextMessage"
                      },
                      {
                        "$ref": "#/components/schemas/ImageMessage"
                      },
                      {
                        "$ref": "#/components/schemas/ButtonMessage"
                      },
                      {
                        "$ref": "#/components/schemas/ChoiceMessage"
                      },
                      {
                        "$ref": "#/components/schemas/CardMessage"
                      },
                      {
                        "$ref": "#/components/schemas/CarouselMessage"
                      },
                      {
                        "$ref": "#/components/schemas/DebugMessage"
                      },
                      {
                        "$ref": "#/components/schemas/FileMessage"
                      },
                      {
                        "$ref": "#/components/schemas/LocationMessage"
                      },
                      {
                        "$ref": "#/components/schemas/TransitionMessage"
                      },
                      {
                        "$ref": "#/components/schemas/ExtensionMessage"
                      },
                      {
                        "$ref": "#/components/schemas/PathMessage"
                      }
                    ]
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error",
            "content": {}
          }
        }
      },
      "post": {
        "tags": ["Messages"],
        "summary": "Push Conversation Messages",
        "description": "Push one or more new messages to a conversation",
        "parameters": [
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "description": "All requests to the ChatDash API must be validated with the agency API Key found on your agency profile",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "agentId",
            "in": "path",
            "required": true,
            "description": "The ID of the agent",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "conversationId",
            "in": "path",
            "required": true,
            "description": "The ID of the conversation",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "messages": {
                    "type": "array",
                    "items": {
                      "oneOf": [
                        {
                          "$ref": "#/components/schemas/TextMessage"
                        },
                        {
                          "$ref": "#/components/schemas/ImageMessage"
                        },
                        {
                          "$ref": "#/components/schemas/ButtonMessage"
                        },
                        {
                          "$ref": "#/components/schemas/ChoiceMessage"
                        },
                        {
                          "$ref": "#/components/schemas/CardMessage"
                        },
                        {
                          "$ref": "#/components/schemas/CarouselMessage"
                        },
                        {
                          "$ref": "#/components/schemas/DebugMessage"
                        },
                        {
                          "$ref": "#/components/schemas/FileMessage"
                        },
                        {
                          "$ref": "#/components/schemas/LocationMessage"
                        },
                        {
                          "$ref": "#/components/schemas/TransitionMessage"
                        },
                        {
                          "$ref": "#/components/schemas/ExtensionMessage"
                        },
                        {
                          "$ref": "#/components/schemas/PathMessage"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "required": false
        },
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string",
                      "example": "Messages added successfully"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string",
                      "example": "An unexpected error occurred"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "put": {
        "tags": ["Messages"],
        "summary": "Overwrite Conversation Messages",
        "description": "Overwrite all messages for a conversation with a new array of messages",
        "parameters": [
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "description": "All requests to the ChatDash API must be validated with the agency API Key found on your agency profile",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "agentId",
            "in": "path",
            "required": true,
            "description": "The ID of the agent",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "conversationId",
            "in": "path",
            "required": true,
            "description": "The ID of the conversation",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "messages": {
                    "type": "array",
                    "items": {
                      "oneOf": [
                        {
                          "$ref": "#/components/schemas/TextMessage"
                        },
                        {
                          "$ref": "#/components/schemas/ImageMessage"
                        },
                        {
                          "$ref": "#/components/schemas/ButtonMessage"
                        },
                        {
                          "$ref": "#/components/schemas/ChoiceMessage"
                        },
                        {
                          "$ref": "#/components/schemas/CardMessage"
                        },
                        {
                          "$ref": "#/components/schemas/CarouselMessage"
                        },
                        {
                          "$ref": "#/components/schemas/DebugMessage"
                        },
                        {
                          "$ref": "#/components/schemas/FileMessage"
                        },
                        {
                          "$ref": "#/components/schemas/LocationMessage"
                        },
                        {
                          "$ref": "#/components/schemas/TransitionMessage"
                        },
                        {
                          "$ref": "#/components/schemas/ExtensionMessage"
                        },
                        {
                          "$ref": "#/components/schemas/PathMessage"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "required": false
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string",
                      "example": "Messages updated successfully"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string",
                      "example": "An unexpected error occurred"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": ["Messages"],
        "summary": "Delete Conversation Messages",
        "description": "Delete all messages for a conversation",
        "parameters": [
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "description": "All requests to the ChatDash API must be validated with the agency API Key found on your agency profile",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "agentId",
            "in": "path",
            "required": true,
            "description": "The ID of the agent",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "conversationId",
            "in": "path",
            "required": true,
            "description": "The ID of the conversation",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string",
                      "example": "Messages deleted successfully"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string",
                      "example": "An unexpected error occurred"
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "TextMessage": {
        "title": "Text Message",
        "type": "object",
        "properties": {
          "sender": {
            "type": "string",
            "enum": ["user", "bot", "agent"]
          },
          "type": {
            "type": "string",
            "enum": ["text"],
            "description": "The type of the message, which is 'text' for TextMessage",
            "example": "text"
          },
          "content": {
            "type": "object",
            "properties": {
              "text": {
                "type": "string",
                "description": "The text of the message"
              }
            }
          },
          "metadata": {
            "type": "object",
            "description": "Token usage or any other metadata for the message",
            "properties": {
              "model": {
                "type": "string",
                "description": "The model for the token usage"
              },
              "total": {
                "type": "number",
                "description": "The total number of tokens used"
              }
            }
          },
          "createdAt": {
            "type": "string",
            "description": "The date and time the message was created"
          }
        },
        "required": ["sender", "type", "content"]
      },
      "ImageMessage": {
        "title": "Image Message",
        "type": "object",
        "properties": {
          "sender": {
            "type": "string",
            "enum": ["user", "bot", "agent"]
          },
          "type": {
            "type": "string",
            "enum": ["image"],
            "description": "The type of the message, which is 'image' for ImageMessage",
            "example": "image"
          },
          "content": {
            "type": "object",
            "properties": {
              "title": {
                "type": "string",
                "description": "The title of the image"
              },
              "imageUrl": {
                "type": "string",
                "description": "The URL of the image"
              }
            }
          },
          "metadata": {
            "type": "object",
            "description": "Any metadata for the message"
          },
          "createdAt": {
            "type": "string",
            "description": "The date and time the message was created"
          }
        },
        "required": ["sender", "type", "content"]
      },
      "ButtonMessage": {
        "title": "Button Message",
        "type": "object",
        "properties": {
          "sender": {
            "type": "string",
            "enum": ["user", "bot", "agent"]
          },
          "type": {
            "type": "string",
            "enum": ["button"],
            "description": "The type of the message, which is 'button' for ButtonMessage",
            "example": "button"
          },
          "content": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string",
                "description": "The name of the button"
              },
              "type": {
                "type": "string",
                "description": "The type of the button"
              },
              "payload": {
                "type": "object",
                "description": "The payload of the button"
              }
            }
          },
          "metadata": {
            "type": "object",
            "description": "Any metadata for the message"
          },
          "createdAt": {
            "type": "string",
            "description": "The date and time the message was created"
          }
        },
        "required": ["sender", "type", "content"]
      },
      "ChoiceMessage": {
        "title": "Choice Message",
        "type": "object",
        "properties": {
          "sender": {
            "type": "string",
            "enum": ["user", "bot", "agent"]
          },
          "type": {
            "type": "string",
            "enum": ["choice"],
            "description": "The type of the message, which is 'choice' for ChoiceMessage",
            "example": "choice"
          },
          "content": {
            "type": "object",
            "properties": {
              "text": {
                "type": "string",
                "description": "Any text for the choice message"
              },
              "choices": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "name": {
                      "type": "string",
                      "description": "The name of the button"
                    },
                    "type": {
                      "type": "string",
                      "description": "The type of the button"
                    },
                    "payload": {
                      "type": "object",
                      "description": "The payload of the button"
                    }
                  }
                }
              }
            }
          },
          "metadata": {
            "type": "object",
            "description": "Any metadata for the message"
          },
          "createdAt": {
            "type": "string",
            "description": "The date and time the message was created"
          }
        },
        "required": ["sender", "type", "content"]
      },
      "CardMessage": {
        "title": "Card Message",
        "type": "object",
        "properties": {
          "sender": {
            "type": "string",
            "enum": ["user", "bot", "agent"]
          },
          "type": {
            "type": "string",
            "enum": ["card"],
            "description": "The type of the message, which is 'card' for CardMessage",
            "example": "card"
          },
          "content": {
            "type": "object",
            "properties": {
              "imageUrl": {
                "type": "string",
                "description": "The URL of the card image"
              },
              "title": {
                "type": "string",
                "description": "The title of the card"
              },
              "description": {
                "type": "string",
                "description": "The description of the card"
              },
              "buttons": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "name": {
                      "type": "string",
                      "description": "The name of the button"
                    },
                    "type": {
                      "type": "string",
                      "description": "The type of the button"
                    },
                    "payload": {
                      "type": "object",
                      "description": "The payload of the button"
                    }
                  }
                }
              }
            }
          },
          "metadata": {
            "type": "object",
            "description": "Any metadata for the message"
          },
          "createdAt": {
            "type": "string",
            "description": "The date and time the message was created"
          }
        },
        "required": ["sender", "type", "content"]
      },
      "CarouselMessage": {
        "title": "Carousel Message",
        "type": "object",
        "properties": {
          "sender": {
            "type": "string",
            "enum": ["user", "bot", "agent"]
          },
          "type": {
            "type": "string",
            "enum": ["carousel"],
            "description": "The type of the message, which is 'carousel' for CarouselMessage",
            "example": "carousel"
          },
          "content": {
            "type": "object",
            "properties": {
              "cards": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "imageUrl": {
                      "type": "string",
                      "description": "The URL of the card image"
                    },
                    "title": {
                      "type": "string",
                      "description": "The title of the card"
                    },
                    "description": {
                      "type": "string",
                      "description": "The description of the card"
                    },
                    "buttons": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "name": {
                            "type": "string",
                            "description": "The name of the button"
                          },
                          "type": {
                            "type": "string",
                            "description": "The type of the button"
                          },
                          "payload": {
                            "type": "object",
                            "description": "The payload of the button"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "metadata": {
            "type": "object",
            "description": "Any metadata for the message"
          },
          "createdAt": {
            "type": "string",
            "description": "The date and time the message was created"
          }
        },
        "required": ["sender", "type", "content"]
      },
      "DebugMessage": {
        "title": "Debug Message",
        "type": "object",
        "properties": {
          "sender": {
            "type": "string",
            "enum": ["user", "bot", "agent"]
          },
          "type": {
            "type": "string",
            "enum": ["debug"],
            "description": "The type of the message, which is 'debug' for DebugMessage",
            "example": "debug"
          },
          "content": {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "description": "The type of the debug message"
              },
              "message": {
                "type": "string",
                "description": "The debug message"
              },
              "tokenUsage": {
                "type": "object",
                "description": "The token usage for the debug message",
                "properties": {
                  "model": {
                    "type": "string",
                    "description": "The model for the token usage"
                  },
                  "total": {
                    "type": "number",
                    "description": "The total number of tokens used"
                  },
                  "query": {
                    "type": "string",
                    "description": "The query for the token usage"
                  },
                  "answer": {
                    "type": "string",
                    "description": "The answer for the token usage"
                  }
                }
              }
            }
          },
          "metadata": {
            "type": "object",
            "description": "Any metadata for the message"
          },
          "createdAt": {
            "type": "string",
            "description": "The date and time the message was created"
          }
        },
        "required": ["sender", "type", "content"]
      },
      "FileMessage": {
        "title": "File Message",
        "type": "object",
        "properties": {
          "sender": {
            "type": "string",
            "enum": ["user", "bot", "agent"]
          },
          "type": {
            "type": "string",
            "enum": ["file"],
            "description": "The type of the message, which is 'file' for FileMessage",
            "example": "file"
          },
          "content": {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "description": "The type of the file"
              },
              "url": {
                "type": "string",
                "description": "The URL of the file"
              },
              "title": {
                "type": "string",
                "description": "The title of the file"
              }
            }
          },
          "metadata": {
            "type": "object",
            "description": "Any metadata for the message"
          },
          "createdAt": {
            "type": "string",
            "description": "The date and time the message was created"
          }
        },
        "required": ["sender", "type", "content"]
      },
      "LocationMessage": {
        "title": "Location Message",
        "type": "object",
        "properties": {
          "sender": {
            "type": "string",
            "enum": ["user", "bot", "agent"]
          },
          "type": {
            "type": "string",
            "enum": ["location"],
            "description": "The type of the message, which is 'location' for LocationMessage",
            "example": "location"
          },
          "content": {
            "type": "object",
            "properties": {
              "latitude": {
                "type": "number",
                "description": "The latitude of the location"
              },
              "longitude": {
                "type": "number",
                "description": "The longitude of the location"
              },
              "address": {
                "type": "string",
                "description": "The address of the location"
              },
              "title": {
                "type": "string",
                "description": "The title of the location"
              }
            }
          },
          "metadata": {
            "type": "object",
            "description": "Any metadata for the message"
          },
          "createdAt": {
            "type": "string",
            "description": "The date and time the message was created"
          }
        },
        "required": ["sender", "type", "content"]
      },
      "TransitionMessage": {
        "title": "Transition Message",
        "type": "object",
        "properties": {
          "sender": {
            "type": "string",
            "enum": ["user", "bot", "agent"]
          },
          "type": {
            "type": "string",
            "enum": ["transition"],
            "description": "The type of the message, which is 'transition' for TransitionMessage",
            "example": "transition"
          },
          "content": {
            "type": "object",
            "properties": {
              "text": {
                "type": "string",
                "description": "The text of the transition message"
              }
            }
          },
          "metadata": {
            "type": "object",
            "description": "Any metadata for the message"
          },
          "createdAt": {
            "type": "string",
            "description": "The date and time the message was created"
          }
        },
        "required": ["sender", "type", "content"]
      },
      "ExtensionMessage": {
        "title": "Extension Message",
        "type": "object",
        "properties": {
          "sender": {
            "type": "string",
            "enum": ["user", "bot", "agent"]
          },
          "type": {
            "type": "string",
            "enum": ["extension"],
            "description": "The type of the message, which is 'extension' for ExtensionMessage",
            "example": "extension"
          },
          "isVisibleOnPrototype": {
            "type": "boolean",
            "description": "The visibility of the extension message on the prototype",
            "default": false
          },
          "content": {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "description": "The type of the extension message"
              },
              "payload": {
                "type": "object",
                "description": "The payload of the extension message"
              },
              "defaultPath": {
                "type": "number",
                "description": "The default path of the extension message"
              },
              "paths": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "event": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "description": "The type of the event"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "metadata": {
            "type": "object",
            "description": "Any metadata for the message"
          },
          "createdAt": {
            "type": "string",
            "description": "The date and time the message was created"
          }
        },
        "required": ["sender", "type", "content"]
      },
      "PathMessage": {
        "title": "Path Message",
        "type": "object",
        "properties": {
          "sender": {
            "type": "string",
            "enum": ["user", "bot", "agent"]
          },
          "type": {
            "type": "string",
            "enum": ["path"],
            "description": "The type of the message, which is 'path' for PathMessage",
            "example": "path"
          },
          "isVisibleOnPrototype": {
            "type": "boolean",
            "description": "The visibility of the extension message on the prototype",
            "default": false
          },
          "content": {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "description": "The type of the path message"
              },
              "payload": {
                "type": "object",
                "description": "The payload of the path message"
              }
            }
          },
          "metadata": {
            "type": "object",
            "description": "Any metadata for the message"
          },
          "createdAt": {
            "type": "string",
            "description": "The date and time the message was created"
          }
        },
        "required": ["sender", "type", "content"]
      }
    }
  },
  "x-original-swagger-version": "2.0"
}
