# Product Enquiry Chat

## Create New Chat/Product enquiry API

The Create New Chat API allows users to initiate a new chat conversation on the e-commerce platform. By using this API, users can send messages to the platform's customer support. Product enquiry will be auto filled with product name to chat box so user can enquire about that specific product.

<figure><img src="https://3686328336-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fd1Iq7THDAagTQzeC9rTN%2Fuploads%2FEOHVkDQsMfeofM4l75vm%2F1aac77c5-035a-4ec8-b551-92a2f612c568.jpg?alt=media&#x26;token=f1591fd4-28e9-46c0-9523-3d5348b23cc2" alt=""><figcaption><p><strong>Chat page with product name auto filled to message</strong></p></figcaption></figure>

### **Endpoint**

* **`{{baseurl}}/api/v1/chat/newChat`**

### **Method**

* **POST**

### **Authorization:**&#x20;

The API requires a valid bearer token in the request header for authentication and user authorization. However, the token is optional, and users can initiate a chat even without providing a token.

### **Request Body:**&#x20;

The API expects a JSON object containing the following parameters:

* `user_id`: The unique identifier of the user initiating the chat.
* `message`: The content of the initial message sent in the chat.
* `token` (optional): A valid authentication token to verify the user's identity and session.

```json
{
  "user_id": 123,
  "message": "Hello, I have a query about my recent order."
}
```

**Response Format:** The API responds with a JSON object containing the chat details, including the chat ID, user ID, message, timestamp, and any additional metadata.

```json

{
    "success": true,
    "message": "success",
    "status_code": 200,
    "chats": [
        {
            "message": "Product name",
            "created_at": "2023-09-28 19:15:22",
            "user": 1,
            "admin": 0
        }
    ],
    "is_allAdminIdle": false


}
```

### Features:

* The API facilitates the creation of new chat conversations on the e-commerce platform.
* Users can interact with the platform's customer support team or other users by sending messages in real-time.
* The chat is identified by a unique `chat_id`, and the message content and timestamp are stored for reference.

### Usage:

The Create New Chat API is utilized when users need to initiate a chat to seek assistance, report an issue, or engage in conversations with other users. It enables seamless communication within the platform and fosters a better user experience.
