{
  "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}/audit-logs": {
      "get": {
        "tags": ["Audit Logs"],
        "summary": "Fetch Agent Audit Logs",
        "description": "Fetch audit logs for a specific agent. Supports filtering by event type, date range, and 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": "eventType",
            "in": "query",
            "required": false,
            "description": "Filter logs by event type",
            "schema": {
              "type": "string",
              "enum": ["ASSIGNMENT", "TAG_UPDATE"]
            }
          },
          {
            "name": "startDate",
            "in": "query",
            "required": false,
            "description": "Start date for filtering logs (ISO 8601)",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "endDate",
            "in": "query",
            "required": false,
            "description": "End date for filtering logs (ISO 8601)",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "conversationId",
            "in": "query",
            "required": false,
            "description": "Optional conversation ID to scope results to one conversation",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Maximum number of logs to return (default: 100)",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "name": "skip",
            "in": "query",
            "required": false,
            "description": "Number of logs to skip for pagination (default: 0)",
            "schema": {
              "type": "integer",
              "minimum": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "example": true
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/AuditLog"
                      }
                    },
                    "pagination": {
                      "$ref": "#/components/schemas/Pagination"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string",
                      "example": "Internal server error"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/conversations/{conversationId}/audit-logs": {
      "get": {
        "tags": ["Audit Logs"],
        "summary": "Fetch Conversation Audit Logs",
        "description": "Fetch audit logs for a specific 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": "conversationId",
            "in": "path",
            "required": true,
            "description": "The ID of the conversation",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "eventType",
            "in": "query",
            "required": false,
            "description": "Filter logs by event type",
            "schema": {
              "type": "string",
              "enum": ["ASSIGNMENT", "TAG_UPDATE"]
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Maximum number of logs to return (default: 50)",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "name": "skip",
            "in": "query",
            "required": false,
            "description": "Number of logs to skip for pagination (default: 0)",
            "schema": {
              "type": "integer",
              "minimum": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "example": true
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/AuditLog"
                      }
                    },
                    "pagination": {
                      "$ref": "#/components/schemas/Pagination"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string",
                      "example": "Internal server error"
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "AuditLog": {
        "type": "object",
        "properties": {
          "_id": { "type": "string" },
          "conversationId": { "type": "string" },
          "agentId": { "type": "string" },
          "timestamp": { "type": "string", "format": "date-time" },
          "eventType": {
            "type": "string",
            "enum": ["ASSIGNMENT", "TAG_UPDATE"]
          },
          "user": {
            "type": "object",
            "properties": {
              "id": { "type": "string" },
              "userType": {
                "type": "string",
                "enum": ["MEMBER", "AGENCY_USER"]
              },
              "name": { "type": "string" }
            }
          },
          "eventDetails": {
            "type": "object",
            "description": "Assignment or tag update details",
            "additionalProperties": true
          }
        }
      },
      "Pagination": {
        "type": "object",
        "properties": {
          "limit": { "type": "integer" },
          "skip": { "type": "integer" },
          "count": { "type": "integer" }
        }
      }
    }
  }
}
