{
  "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}/leads": {
      "get": {
        "tags": ["Leads"],
        "summary": "Fetch Agent Leads",
        "description": "Fetch all leads for a specific agent",
        "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"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "_id": {
                        "type": "string",
                        "description": "The ID of the lead"
                      },
                      "phone": {
                        "type": "string",
                        "description": "The phone number of the lead"
                      },
                      "customFields": {
                        "type": "object",
                        "additionalProperties": {
                          "type": "string"
                        },
                        "description": "The user defined fields for the lead. Keys are field names, values are field values."
                      },
                      "tags": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        },
                        "description": "The IDs of the tags attached to the lead"
                      }
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error",
            "content": {}
          }
        }
      },
      "post": {
        "tags": ["Leads"],
        "summary": "Create Leads",
        "description": "Create one or more new leads for a agent",
        "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"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "phone": {
                      "type": "string",

                      "description": "The phone number of the lead"
                    },
                    "customFields": {
                      "type": "object",
                      "additionalProperties": {
                        "type": "string"
                      },
                      "description": "The user defined fields for the lead. Keys are field names, values are field values."
                    },
                    "tags": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      },
                      "description": "The IDs of the tags attached to the lead"
                    }
                  },
                  "required": ["phone"]
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "_id": {
                        "type": "string",
                        "description": "The ID of the lead"
                      },
                      "phone": {
                        "type": "string",
                        "description": "The phone number of the lead"
                      },
                      "customFields": {
                        "type": "object",
                        "additionalProperties": {
                          "type": "string"
                        },
                        "description": "The user defined fields for the lead. Keys are field names, values are field values."
                      },
                      "tags": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        },
                        "description": "The IDs of the tags attached to the lead"
                      }
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string",
                      "example": "An unexpected error occurred"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/agents/{agentId}/leads/{leadId}": {
      "put": {
        "tags": ["Leads"],
        "summary": "Update Lead",
        "description": "Update a lead for a agent",
        "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": "leadId",
            "in": "path",
            "required": true,
            "description": "The ID of the lead",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "phone": {
                    "type": "string",
                    "description": "The phone number of the lead"
                  },
                  "customFields": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "string"
                    },
                    "description": "The user defined fields for the lead. Keys are field names, values are field values."
                  },
                  "tags": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "The IDs of the tags attached to the lead"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "_id": {
                      "type": "string",
                      "description": "The ID of the lead"
                    },
                    "phone": {
                      "type": "string",
                      "description": "The phone number of the lead"
                    },
                    "customFields": {
                      "type": "object",
                      "additionalProperties": {
                        "type": "string"
                      },
                      "description": "The user defined fields for the lead. Keys are field names, values are field values."
                    },
                    "tags": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      },
                      "description": "The IDs of the tags attached to the lead"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error",
            "content": {}
          }
        }
      },
      "delete": {
        "tags": ["Leads"],
        "summary": "Delete Lead",
        "description": "Delete a lead for a agent",
        "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": "leadId",
            "in": "path",
            "required": true,
            "description": "The ID of the lead",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "OK - Lead successfully deleted",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {}
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error",
            "content": {}
          }
        }
      }
    },
    "/agents/{agentId}/leads/tags": {
      "get": {
        "tags": ["Leads"],
        "summary": "Fetch Tags",
        "description": "Fetch all tags used for leads in a specific agent",
        "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"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK - List of lead tags",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "_id": {
                        "type": "string",
                        "description": "The ID of the tag"
                      },
                      "label": {
                        "type": "string",
                        "description": "The label of the tag"
                      },
                      "system": {
                        "type": "boolean",
                        "description": "Whether the tag is a system tag"
                      },
                      "systemLabel": {
                        "type": "string",
                        "description": "The system label of the tag"
                      }
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error",
            "content": {}
          }
        }
      },
      "post": {
        "tags": ["Leads"],
        "summary": "Create Tag",
        "description": "Create a new tag for leads in a agent",
        "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"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "label": {
                    "type": "string",
                    "description": "The label of the tag"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created - Tag successfully created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "_id": {
                      "type": "string",
                      "description": "The ID of the tag"
                    },
                    "label": {
                      "type": "string",
                      "description": "The label of the tag"
                    },
                    "system": {
                      "type": "boolean",
                      "description": "Whether the tag is a system tag"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error",
            "content": {}
          }
        }
      }
    },
    "/agents/{agentId}/leads/tags/{tagId}": {
      "put": {
        "tags": ["Leads"],
        "summary": "Update Tag",
        "description": "Update a tag for leads in a agent",
        "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": "tagId",
            "in": "path",
            "required": true,
            "description": "The ID of the tag",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "label": {
                    "type": "string",
                    "description": "The label of the tag"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK - Tag successfully updated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "_id": {
                      "type": "string",
                      "description": "The ID of the tag"
                    },
                    "label": {
                      "type": "string",
                      "description": "The label of the tag"
                    },
                    "system": {
                      "type": "boolean",
                      "description": "Whether the tag is a system tag"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error",
            "content": {}
          }
        }
      },
      "delete": {
        "tags": ["Leads"],
        "summary": "Delete Tag",
        "description": "Delete a tag for leads in a agent",
        "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": "tagId",
            "in": "path",
            "required": true,
            "description": "The ID of the tag",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "OK - Tag successfully deleted",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {}
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error",
            "content": {}
          }
        }
      }
    }
  },
  "components": {},
  "x-original-swagger-version": "2.0"
}
