# Deal

## 1. Tạo mới deal

<mark style="color:green;">`POST`</mark> `/{domain}/api/v1/deal`

Tạo mới deal

**Headers**

| Name          | Value              |
| ------------- | ------------------ |
| Content-Type  | `application/json` |
| Authorization | `Bearer <token>`   |

**JSON body payload**

| STT | Param                                   | Kiểu dữ liệu | Độ dài      | Ghi chú                                                                                                                                          |
| --- | --------------------------------------- | ------------ | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| 1\* | deal                                    | object       | <p><br></p> | Đối tượng chứa thông tin lead                                                                                                                    |
| ..  | <p><br>Các trường trong object deal</p> | <p><br></p>  | <p><br></p> | <p><br></p>                                                                                                                                      |
| 1   | username                                | Text         | 250         | Họ tên khách hàng (Trong trường hợp số điện thoại hoặc email của khách đã tồn tại sẽ không sử dụng tham số này)                                  |
| 2   | subject (\*)                            | text         | 250         | Tiêu đề                                                                                                                                          |
| 3   | phone (\*)                              | tel          | 50          | Số điện thoại của khách hàng                                                                                                                     |
| 4   | email (\*)                              | email        | 50          | Email của khách hàng                                                                                                                             |
| 5   | service\_id  (\*\*)                     | Int          | 10          | Dịch vụ tiếp nhận Lead                                                                                                                           |
| 6   | group\_id (\*\*)                        | Int          | 10          | ID bộ phận tiếp nhận                                                                                                                             |
| 7   | assignee\_id (\*\*)                     | Int          | 10          | ID chuyên viên tiếp nhận                                                                                                                         |
| 8   | pipeline\_id                            | Int          | 10          | [ID tiến trình ](#id-5.1-danh-sach-cac-tien-trinh-va-giai-doan)(Mặc định theo cấu hình)                                                          |
| 9   | estimated\_closed\_date                 | DateTime     | <p><br></p> | Dự kiến hoàn thành (Định dạng YYYY-MM-DD HH:mm:ss)                                                                                               |
| 10  | deal\_label                             | Array        | <p><br></p> | <p>Mảng ID label của deal dạng \[1,2,3]</p><p><br></p>                                                                                           |
| 11  | pipeline\_stage\_id                     | Int          | <p><br></p> | I[D giai đoạn của tiến trình](#id-5.1-danh-sach-cac-tien-trinh-va-giai-doan) (mặc định là đầu giai đoạn)                                         |
| 12  | custom\_fields                          | Array        | <p><br></p> | Mảng custom\_fields tương tự tạo ticket                                                                                                          |
| 13  | probability                             | Int          | 10          | Tỉ lệ thành công (từ 0-100)                                                                                                                      |
| 14  | value                                   | Int          | 10          | Giá trị đơn hàng (Số)                                                                                                                            |
| 15  | comment                                 | Text         | 5000        | Nội dung ghi chú                                                                                                                                 |
| 9   | comment.body                            | Text         | 5000        | Nội dung comment                                                                                                                                 |
| 10  | comment.is\_public                      | Int          | 1           | <p>Trạng thái comment<br>0: Ghi chú<br>1: Public (VD: Gửi email cho người yêu cầu …) </p>                                                        |
| 11  | comment.author\_id                      | Int          | 10          | ID của người bình luận                                                                                                                           |
| 12  | order\_address\_detail                  | String       | 255         | Địa chỉ chi tiết                                                                                                                                 |
| 13  | order\_buyer\_note                      | String       | 500         | Ghi chú của người mua                                                                                                                            |
| 14  | order\_city\_id                         | String       | 10          | ID của tỉnh (Theo danh sách [Tỉnh thành](/danh-muc/restful-api-cua-caresoft/khach-hang/thong-tin-tinh-huyen-xa.md#lay-danh-sach-tinh-thanh-pho)) |
| 15  | order\_district\_id                     | String       | 10          | ID của huyện/quận (Theo danh sách  quận huyện)                                                                                                   |
| 16  | order\_ward\_id                         | String       | 10          | ID của Xã/phường (Theo danh sách xã phường)                                                                                                      |
| 17  | order\_receiver\_name                   | String       | 200         | Người nhận                                                                                                                                       |
| 18  | order\_receiver\_phone                  | String       | 20          | Số ĐT người nhận                                                                                                                                 |
| 19  | order\_shipping\_fee                    | Float        |             | Cước vận chuyển                                                                                                                                  |
| 20  | order\_status                           | String       | 50          | Là một trong danh sách sau - [Danh sách trạng thái](#user-content-fn-1)[^1]                                                                      |
| 21  | order\_tracking\_code                   | String       | 50          | Mã vận chuyển                                                                                                                                    |
| 22  | order\_tracking\_url                    |              | 500         | Đường dẫn kiểm tra trạng thái vận chuyển                                                                                                         |
| 23  | order\_products                         | Array        |             | <p>Mảng sản phẩm (<a data-footnote-ref href="#user-content-fn-2">Xem chi tiết trong mẫu</a>) <br></p>                                            |

**Mẫu Payload**

```json
{
  "deal": {
    "phone": "0983980148",
    "subject": "Test referer url",
    "value": "233333",
    "probability": 23,
    "estimated_closed_date": "2024/03/21 23:59:59",
    "deal_label": [
      10,
      11
    ],
    "pipeline_id": 56,
    "pipeline_stage_id": "377",
    "custom_fields": [
      {
        "id": "6068",
        "value": "106902"
      }
    ]
  }
}
```

**Mẫu phản hồi**

{% tabs %}
{% tab title="200" %}

```json
{
    "code": "ok",
    "deal": {
        "updated_at": "2024-03-21 15:04:04",
        "subject": "Test referer url",
        "created_at": "2024-03-21 15:04:04",
        "id": 414856013,
        "requester_id": 63215969
    }
}

```

{% endtab %}

{% tab title="400" %}

```json
{
  "error": "Invalid request"
}
```

{% endtab %}
{% endtabs %}

## 2. Cập nhật deal

<mark style="color:green;">`PUT`</mark> `/{domain}/api/v1/deal/{dealId}`

Cập nhật deal cần ID được lấy từ giá trị deal.id ở tiến trình tạo deal hoặc từ các nguồn khai thác đã tạo deal từ trước.

**Headers**

| Name          | Value              |
| ------------- | ------------------ |
| Content-Type  | `application/json` |
| Authorization | `Bearer <token>`   |

**JSON body payload**

| STT | Param                   | Kiểu dữ liệu | Độ dài      | Ghi chú                                                                                                     |
| --- | ----------------------- | ------------ | ----------- | ----------------------------------------------------------------------------------------------------------- |
| 1\* | deal                    | object       | <p><br></p> | Đối tượng chứa thông tin lead                                                                               |
| ….  | <p><br></p>             | <p><br></p>  | <p><br></p> | <p><br></p>                                                                                                 |
| 2   | subject                 | text         | 250         | Tiêu đề                                                                                                     |
| 7   | assignee\_id            | Int          | 10          | ID chuyên viên tiếp nhận                                                                                    |
| 8   | pipeline\_id            | Int          | 10          | ID tiến trình (Mặc định theo cấu hình)                                                                      |
| 9   | estimated\_closed\_date | DateTime     | <p><br></p> | Dự kiến hoàn thành (Định dạng YYYY-MM-DD HH:mm:ss)                                                          |
| 10  | deal\_label             | Array        | <p><br></p> | <p>Mảng ID label của deal dạng \[1,2,3]</p><p><br></p>                                                      |
| 11  | pipeline\_stage\_id     | Int          | <p><br></p> | ID giai đoạn của tiến trình (mặc định là đầu giai đoạn)                                                     |
| 12  | custom\_fields          | Array        | <p><br></p> | Mảng custom\_fields tương tự tạo ticket                                                                     |
| 13  | probability             | Int          | 10          | Tỉ lệ thành công (từ 0-100)                                                                                 |
| 14  | value                   | INt          | 10          | Giá trị đơn hàng (Số)                                                                                       |
| 15  | comment (\*)            | Object       | <p><br></p> | Nội dung ghi chú                                                                                            |
| 16  | order\_address\_detail  | String       | 255         | Địa chỉ chi tiết                                                                                            |
| 17  | order\_buyer\_note      | String       | 20          | Ghi chú của người mua                                                                                       |
| 18  | order\_city\_id         | String       | 10          | ID tỉnh thành trên CareSoft                                                                                 |
| 19  | order\_district\_id     | String       | 10          | ID huyện trên CareSoft                                                                                      |
| 20  | order\_ward\_id         | String       | 10          | ID xã trên CareSoft                                                                                         |
| 21  | order\_receiver\_name   | String       | 299         | Người nhận                                                                                                  |
| 22  | order\_receiver\_phone  | String       | 29          | SDT người nhận                                                                                              |
| 23  | order\_shipping\_fee    | Float        |             | Giá cước                                                                                                    |
| 24  | order\_status           | String       | 50          | Trạng thái đơn hàng, Là một trong[  (Danh sách )](#user-content-fn-3)[^3]                                   |
| 25  | order\_tracking\_code   | String       | 59          | Mã vận chuyển                                                                                               |
| 26  | order\_tracking\_url    | String       | 500         | <p>Đường dẫn kiểm tra trạng thái vận chuyển</p><p><br></p>                                                  |
| 27  | order\_products         | Array        |             | <p>Mảng sản phẩm (Xem <a data-footnote-ref href="#user-content-fn-4">chi tiết trong mẫu</a>)</p><p><br></p> |

**Mẫu JSON BODY**

```json
{
  "deal": {
    "subject": "Tesst",
    "comment": {
      "body": "Cập nhật giá trị mua hành thành giao hàng",
      "is_public": 1,
      "author_id": 124734559
    },
    "pipeline_stage_id": 1,
    "pipeline_id": 122,
    "probability": "70",
    "value": "200000",
    "estimated_closed_date": "2024-04-11 00:00:00",
    "deal_label": [
      11,
      22
    ],
    "custom_fields": [
      {
        "id": "6068",
        "value": "106902"
      }
    ]
  }
}
```

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
    "code": "ok",
    "deal": {
        "updated_at": "2024-03-21 15:04:04",
        "subject": "Test referer url",
        "created_at": "2024-03-21 15:04:04",
        "id": 414856013,
        "requester_id": 63215969
    }
}

```

{% endtab %}

{% tab title="400" %}

```json
{
  "error": "Invalid request"
}
```

{% endtab %}
{% endtabs %}

## 3. Chi tiết deal

<mark style="color:green;">`GET`</mark> `/{domain}/api/v1/deal/{dealId}`

Lấy chi tiết 1 deal theo tham số dealID được tạo từ bước 1 hoặc được khai thác từ quá trình đồng bộ

&#x20;Các tham số của Deal gồm

* converted\_at: Ngày chuyển đổi
* converted\_by: ID chuyên viên chuyển đổi
* converted\_type: Kiểu chuyển đổi ( 1: Chuyển thành deal, 2: Chuyển thành không đạt
* lead\_status\_id: Id của trạng thái lead ( mục I.2)
* last\_lead\_status\_id: ID trạng thái trước khi chuyển đổi
* unqualified\_reasons: [Id Lý do không đạt](#id-5.2-ly-do-khong-dat) (Xem mục I.4)
* labels : nhãn của Lead  (Xem mục I.3)
* estimated\_closed\_date: thời gian dự kiến hoàn thành&#x20;
* closed\_at: Thời gian đóng deal&#x20;
* closed\_by: Người đóng deal&#x20;
* closed\_type: Kiểu đóng deal( kiểu Won/ Lost/ Unqualified)
* pipeline\_id: ID tiến trình của deal&#x20;
* pipeline\_stage\_id: ID giai đoạn của deal
* value: Giá trị của deal
* probability: Tỷ lệ thành công của deal&#x20;
* last\_deal\_stage\_id: ID giai đoạn cuối trước khi đóng của deal&#x20;
* lost\_reasons: [Lý do mất của deal ](#id-5.3-ly-do-mat-don)
* order\_address\_detail: Chi tiết địa chỉ giao hàng
* order\_buyer\_note: Ghi chú của người mua
* order\_city\_id: ID City (Theo danh sách [thành phố](/danh-muc/restful-api-cua-caresoft/khach-hang/thong-tin-tinh-huyen-xa.md#lay-danh-sach-tinh-thanh-pho))
* order\_district\_id: ID quận huyện (Theo danh sách [quận huyện](/danh-muc/restful-api-cua-caresoft/khach-hang/thong-tin-tinh-huyen-xa.md#lay-danh-sach-tinh-thanh-pho-1))
* order\_ward\_id: ID phường xã  (Theo danh sách[ phường xã](/danh-muc/restful-api-cua-caresoft/khach-hang/thong-tin-tinh-huyen-xa.md#lay-danh-sach-tinh-thanh-pho-1) )
* order\_receiver\_name: Tên người nhận
* order\_receiver\_phone: Số điện thoại người nhận đơn
* order\_shipping\_fee: Giá cước vận chuyển
* order\_payment: Phương thức thanh toán
* order\_status:  Trạng thái đặt hàng, ORDER\_STARTED&#x20;
* order\_tracking\_code: Mã vận chuyển
* order\_tracking\_url: Đường dẫn tra cứu vận chuyển của nhà cung cấp dịch vụ
* order\_products: \[...]. Mảng sản phẩm đặt mua
  * name:Tên sản phẩm
  * sku: SKU sản phẩm,&#x20;
  * is\_free: Là sản phẩm tặng kèm (1) hoặc bình thường (0)&#x20;
  * unit\_price: Đơn giá&#x20;
  * quantity: Số lượng
  * discount\_markup:Giảm giá bằng %
  * discount\_value: Giảm giá bằng tiền
  * total\_amount: Tổng tiền của sản phẩm&#x20;

**Headers**

| Name          | Value              |
| ------------- | ------------------ |
| Content-Type  | `application/json` |
| Authorization | `Bearer <token>`   |

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
  "deal": {
    "account_id": 8187,
    "id": 474845380,
    "deal_no": 13241,
    "requester_id": 156011012,
    "group_id": 14181,
    "ticket_source_end_status": null,
    "assignee_id": 124733804,
    "ticket_source": "Facebook",
    "merge_status": null,
    "merge_to": null,
    "clone_from": null,
    "subject": "Test Deal",
    "created_at": "2024-03-16 02:22:55",
    "updated_at": "2024-10-21 13:58:39",
    "duedate": null,
    "satisfaction": null,
    "satisfaction_content": null,
    "satisfaction_at": null,
    "satisfaction_send": null,
    "campaign_id": null,
    "campaign_action_id": null,
    "campaign_status": null,
    "automessage_id": null,
    "manualmessage_id": null,
    "incident_id": -1,
    "service_id": 91047363,
    "qa_script_id": null,
    "qa_agent": null,
    "current_agent": null,
    "ticket_source_detail_id": 290025,
    "convert_by": null,
    "convert_at": null,
    "convert_type": null,
    "unqualified_reasons": 0,
    "last_lead_status_id": null,
    "lead_status_id": null,
    "estimated_closed_date": "2024-10-23 23:59:59",
    "closed_at": "2024-10-12 01:48:54",
    "closed_by": 124733804,
    "closed_type": 3,
    "pipeline_id": 17,
    "pipeline_stage_id": 129,
    "value": 1000,
    "probability": 40,
    "last_deal_stage_id": 125,
    "lost_reasons": null,
    "order_address_detail": "Đơn hàng từ Khách lẻ",
    "order_buyer_note": "Giao giờ hành chính",
    "order_city_id": "01",
    "order_district_id": "021",
    "order_receiver_name": "windy",
    "order_receiver_phone": "03466****66",
    "order_shipping_fee": 30000,
    "order_payment": null,
    "order_status": "ORDER_STARTED",
    "order_tracking_code": "122xxx",
    "order_tracking_url": "https://shippingprovider..../?trackingId=",
    "order_ward_id": "00617",
    "order_products": [
      {
        "name": "Boots",
        "sku": "2",
        "is_free": 0,
        "unit_price": 50000,
        "quantity": 1,
        "discount_markup": 10,
        "discount_value": 0,
        "total_amount": 45000
      },
      {
        "name": "Harpic White and Shine Disinfectant Toilet Cleaner Bleach - 500 ml | India's # 1 Toilet Cleaner",
        "sku": "11",
        "is_free": 0,
        "unit_price": 6245,
        "quantity": 1,
        "discount_markup": 0,
        "discount_value": 2000,
        "total_amount": 4245
      }
    ],
    "comments": [
      {
        "ticket_comments_id": 1224857808,
        "ticket_id": 474845380,
        "comment": "1",
        "commentator_id": 124734559,
        "username": "Admin1",
        "facebook": null,
        "facebook_name": null,
        "comment_source": null,
        "created_at": "2024-10-21 13:58:39",
        "attack_file_id": null,
        "file_name": null,
        "file_id": null,
        "download_connection_string": null,
        "call_id": null,
        "email_receive_id": null,
        "addition_details": null,
        "is_public": 0,
        "can_hide": null,
        "can_remove": null,
        "can_reply_privately": null,
        "facebook_comment_state": 0,
        "role_id": 1,
        "avatar": "https://3.bp.blogspot.com/-qCI9fu4I2SE/Y7UkNAM4jhI/AAAAAAAENjs/YWNtRIeDGjghZbiZmu9aduswuxvmuTYSACNcBGAsYHQ/photo.png?imgmax=3000"
      }
    ],
    "custom_fields": [
      {
        "id": 5159,
        "label": "Kí tự 19",
        "type": "Text",
        "value": null
      },
      {
        "id": 6055,
        "label": "Địa chỉ link 19",
        "type": "Link",
        "value": null
      },
      {
        "id": 9579,
        "label": "Phân loại ticket cha(2602)",
        "type": "Single drop-down list",
        "value": null
      }
    ],
    "tags": [],
    "ccs": [
      {
        "id": 156011012,
        "username": "Hùng Nguyễn",
        "email": "Nj@hj.vn"
      }
    ],
    "follows": [],
    "labels": [
      {
        "id": 32,
        "label": "New letter",
        "updated_at": "2024-10-21 13:58:39"
      },
      {
        "id": 31,
        "label": "No Label",
        "updated_at": "2024-10-21 13:58:39"
      }
    ],
    "assignee": {
      "id": 124733804,
      "username": "Hùng zx",
      "email": "hungnx1@caresoft.vn",
      "phone_no": "0334992975",
      "agent_id": "50000",
      "role_id": 1,
      "group_id": 14181,
      "group_name": "ORV"
    },
    "requester": {
      "id": 156011012,
      "username": "Sample",
      "email": "abc@gamil.com",
      "phone_no": "09***12009",
      "organization_id": 245826,
      "organization": {
        "organization_id": 245826,
        "organization_domain": "",
        "organization_name": "Sample org"
      }
    }
  }
}
```

{% endtab %}

{% tab title="400" %}

```json
{
  "error": "Invalid request"
}
```

{% endtab %}
{% endtabs %}

## 4. Danh sách deals

<mark style="color:green;">`GET`</mark> `/{domain}/api/v1/deals`

Danh sách deal đang có trên hệ thống

**Headers**

| Name          | Value              |
| ------------- | ------------------ |
| Content-Type  | `application/json` |
| Authorization | `Bearer <token>`   |

**Parameters**

| Param          | Ghi chú                                                                                                    |
| -------------- | ---------------------------------------------------------------------------------------------------------- |
| requester\_id  | ID Người yêu cầu                                                                                           |
| assignee\_id   | ID Chuyên viên                                                                                             |
| service\_id    | ID dịch vụ                                                                                                 |
| page           | Trang số (mặc định 1)                                                                                      |
| count          | Số bản ghi /trang (mặc định 50, max 500)                                                                   |
| created\_since | <p>Ngày tạo từ (Kiểu Time TZ)<br>Vd: 2024-06-01T00:00:00Z</p>                                              |
| created\_to    | <p>Ngày tạo tới (Kiểu Time TZ)<br>Vd: 2024-06-01T00:00:00Z</p>                                             |
| updated\_since | <p>Ngày cập nhật từ (Kiểu Time TZ)<br>Vd: 2024-06-01T00:00:00Z</p><p><br></p>                              |
| updated\_to    | <p>Ngày cập nhật tới (Kiểu Time TZ)<br>Vd: 2024-06-01T00:00:00Z</p><p><br></p>                             |
| convert\_since | <p>Ngày chuyển đổi thành deal (từ lead) (Kiểu Time TZ)<br>Vd: 2024-06-01T00:00:00Z</p><p><br></p>          |
| convert\_to    | <p>Ngày chuyển đổi thành deal tới (Kiểu Time TZ)<br>Vd: 2024-06-01T00:00:00Z</p><p><br></p>                |
| closed\_since  | <p>Ngày đóng Deal  từ  (Kiểu Time TZ)<br>Vd: 2024-06-01T00:00:00Z</p><p><br></p>                           |
| closed\_to     | <p>Ngày đóng Deal  tới (Kiểu Time TZ)<br>Vd: 2024-06-01T00:00:00Z</p>                                      |
| pipeline\_ids  | <p>ID Tiến trình  chọn nhiều  cách nhau bởi dấu phẩy<br>VD: 12 hoặc 12,34,56</p>                           |
| stage\_ids     | <p>ID  chọn nhiều cách nhau bởi dấu phẩy<br>VD: 12 hoặc 12,34,56</p>                                       |
| closed\_type   | <p>Trạng thái đóng:<br>1:  Thành công, 2: Mất Deal , 3: Không đạt </p>                                     |
| convert\_type  | <p>Trạng thái chuyển đổi từ lead sang deal</p><p>1:Chuyển thành Deal , 2:  Chuyển thành unqualified.  </p> |

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
    "code": "ok",
    "numFound": 2,
    "deals": [
        {
            "id": 414858584,
            "deal_no": 275062,
            "requester_id": 63203703,
            "ticket_source_end_status": null,
            "assignee_id": 63203703,
            "ticket_priority": "Normal",
            "ticket_source": "Web",
            "is_overdue": null,
            "subject": "csxcsxdv",
            "created_at": "2024-05-24T17:22:21Z",
            "updated_at": "2024-05-27T11:32:17Z",
            "duedate": null,
            "service_id": null,
            "incident_id": -1,
            "satisfaction": null,
            "satisfaction_at": null,
            "satisfaction_content": null,
            "campaign_id": null,
            "automessage_id": null,
            "ticket_source_detail_id": null,
            "convert_by": null,
            "convert_at": null,
            "convert_type": null,
            "unqualified_reasons": null,
            "last_lead_status_id": null,
            "lead_status_id": null,
            "estimated_closed_date": "2024-05-24 23:59:59",
            "closed_at": "2024-05-27 11:06:02",
            "closed_by": 63203703,
            "closed_type": 2,
            "pipeline_id": 56,
            "pipeline_stage_id": 382,
            "value": 0,
            "probability": 20,
            "last_deal_stage_id": 377,
            "lost_reasons": 79
        },
        {
            "id": 414857144,
            "deal_no": 273806,
            "requester_id": 1,
            "ticket_source_end_status": null,
            "assignee_id": 1,
            "ticket_priority": "Normal",
            "ticket_source": "Web",
            "is_overdue": null,
            "subject": "xxxx",
            "created_at": "2024-05-07T13:46:14Z",
            "updated_at": "2024-05-07T17:48:36Z",
            "duedate": null,
            "service_id": null,
            "incident_id": -1,
            "satisfaction": null,
            "satisfaction_at": null,
            "satisfaction_content": null,
            "campaign_id": null,
            "automessage_id": null,
            "ticket_source_detail_id": null,
            "convert_by": null,
            "convert_at": null,
            "convert_type": null,
            "unqualified_reasons": null,
            "last_lead_status_id": null,
            "lead_status_id": null,
            "estimated_closed_date": null,
            "closed_at": "2024-05-07 17:48:36",
            "closed_by": 29370874,
            "closed_type": 2,
            "pipeline_id": 56,
            "pipeline_stage_id": 382,
            "value": 0,
            "probability": 5,
            "last_deal_stage_id": 376,
            "lost_reasons": 85
        }
    ]
}

```

{% endtab %}

{% tab title="400" %}

```json
{
  "error": "Invalid request"
}
```

{% endtab %}
{% endtabs %}

## 5. Các API liên quan khác

## 5.1 Danh sách Các tiến trình và giai đoạn

<mark style="color:green;">`GET`</mark> `/{domain}/api/v1/deal/pipelines`

**Headers**

| Name          | Value              |
| ------------- | ------------------ |
| Content-Type  | `application/json` |
| Authorization | `Bearer <token>`   |

**Response**

{% tabs %}
{% tab title="200" %}

```json

{
    "code": "ok",
    "data": [
        {
            "id": 41,
            "label": "Sale pipeline",
            "created_at": "2024-03-01 09:43:10",
            "updated_at": "2024-03-30 00:40:06",
            "default": 0,
            "stages": [
                {
                    "id": 296,
                    "pipeline_id": 41,
                    "stage_name": "Tư vấn triển khai ",
                    "stage_type": 1,
                    "probability": 50
                },
                {
                    "id": 298,
                    "pipeline_id": 41,
                    "stage_name": "Hợp đồng báo giá",
                    "stage_type": 0,
                    "probability": 20
                },
                {
                    "id": 299,
                    "pipeline_id": 41,
                    "stage_name": "Vận đơn Logistic",
                    "stage_type": 0,
                    "probability": 70
                },
                {
                    "id": 300,
                    "pipeline_id": 41,
                    "stage_name": "Thanh toán thành công",
                    "stage_type": 2,
                    "probability": 0
                },
                {
                    "id": 301,
                    "pipeline_id": 41,
                    "stage_name": "Hoàn hàng ",
                    "stage_type": 3,
                    "probability": 0
                },
                {
                    "id": 302,
                    "pipeline_id": 41,
                    "stage_name": "Đổi trả ",
                    "stage_type": 4,
                    "probability": 0
                }
            ]
        } 
        
      
    ]
}
```

{% endtab %}

{% tab title="400" %}

```json
{
  "error": "Invalid request"
}
```

{% endtab %}
{% endtabs %}

## 5.2 Lý do không đạt&#x20;

<mark style="color:green;">`GET`</mark>`/{domain}/api/v1/deal/unqualified-reasons`

**Headers**

| Name          | Value              |
| ------------- | ------------------ |
| Content-Type  | `application/json` |
| Authorization | `Bearer <token>`   |

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
    "code": "ok",
    "data": [
        {
            "id": 193,
            "label": "No need"
        },
        {
            "id": 194,
            "label": "Not the decision maker"
        },
        {
            "id": 195,
            "label": "No budget"
        },
        {
            "id": 196,
            "label": "Not the right timing"
        },
        {
            "id": 197,
            "label": "Other"
        }
    ]
}

```

{% endtab %}

{% tab title="400" %}

```json
{
  "error": "Invalid request"
}
```

{% endtab %}
{% endtabs %}

## 5.3 Lý do mất đơn

<mark style="color:green;">`POST`</mark> `/{domain}/api/v1/deal/lost-reasons`

\<Description of the endpoint>

**Headers**

| Name          | Value              |
| ------------- | ------------------ |
| Content-Type  | `application/json` |
| Authorization | `Bearer <token>`   |

**Body**

| Name   | Type   | Description      |
| ------ | ------ | ---------------- |
| `name` | string | Name of the user |
| `age`  | number | Age of the user  |

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
    "code": "ok",
    "data": [
        {
            "id": 20,
            "label": "Lost to competiton"
        },
        {
            "id": 21,
            "label": "Poor follow up"
        },
        {
            "id": 22,
            "label": "We are too expensive"
        },
        {
            "id": 23,
            "label": "Timing Gap"
        }
    ]
}
```

{% endtab %}

{% tab title="400" %}

```json
{
  "error": "Invalid request"
}
```

{% endtab %}
{% endtabs %}

## 5.4 Deal labels&#x20;

<mark style="color:green;">`GET`</mark> `/{domain}/api/v1/deal/labels`

**Headers**

| Name          | Value              |
| ------------- | ------------------ |
| Content-Type  | `application/json` |
| Authorization | `Bearer <token>`   |

**Body**

| Name   | Type   | Description      |
| ------ | ------ | ---------------- |
| `name` | string | Name of the user |
| `age`  | number | Age of the user  |

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
    "code": "ok",
    "data": [
        {
            "id": 37,
            "label": "Automation",
            "created_at": "2023-10-27 23:18:55",
            "updated_at": "2023-10-27 23:18:55"
        },
        {
            "id": 29,
            "label": "Cold Deal",
            "created_at": "2023-10-27 23:16:34",
            "updated_at": "2023-10-27 23:16:34"
        }, 
        {
            "id": 30,
            "label": "Web Form",
            "created_at": "2023-10-27 23:16:45",
            "updated_at": "2023-10-27 23:16:45"
        }
    ]
}
```

{% endtab %}

{% tab title="400" %}

```json
{
  "error": "Invalid request"
}
```

{% endtab %}
{% endtabs %}

[^1]: "ORDER\_STARTED":  Khởi tạo đơn hàng

    "BUYER\_CONFIRMED": Người mua xác nhận

    "SELLER\_CONFIRMED:  Nhà bán xác nhận

    "SHIPPING": Đang vận chuyển

    "RETURNED": Hoàn

    "CANCELED": Hủy

    "RECEIVED"": Đã nhận

[^2]: &#x20;"sku": Mã sản phẩm

    &#x20;"is\_free": Hàng tặng "1", Mặc định 0

    &#x20;"unit\_price": Giá tiền

    &#x20;"quantity":  Số lượng

    &#x20;"discount\_markup": Tỉ lệ giảm giá,  "discount\_value":  Giảm giá bằng  tiền&#x20;

[^3]: "ORDER\_STARTED": Khởi tạo đơn hàng&#x20;

    "BUYER\_CONFIRMED": Người mua xác nhận&#x20;

    "SELLER\_CONFIRMED: Nhà bán xác nhận

    "SHIPPING": Đang vận chuyển

    "RETURNED": Hoàn

    "CANCELED": Hủy

    "RECEIVED"": Đã nhận

[^4]: "sku": Mã sản phẩm

    "is\_free": Hàng tặng "1", Mặc định 0

    "unit\_price": Giá tiền

    "quantity": Số lượng

    "discount\_markup": Tỉ lệ giảm giá, "discount\_value": Giảm giá bằng tiền


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.caresoft.vn/danh-muc/restful-api-cua-caresoft/deal.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
