# Thêm khách hàng

* API này dùng để thêm khách hàng.
* Tối đa mỗi lần không quá 100 khách hàng.

## Request

* Xem [common request params](/v3/readme.md#request-params).

```curl
curl --location 'https://pos.open.nhanh.vn/v3.0/customer/add?appId={{appId}}&businessId={{businessId}}' \
--header 'Authorization: {{accessToken}}' \
--header 'Content-Type: application/json'
--data '[
  {
    "name": "Nguyễn Văn A",
    "mobile": "0989999998",
    "locations": {
      "cityId": 254,
      "districtId": 320,
      "wardId": 1108
    }
  },
  {
    "name": "Nguyễn Văn B",
    "mobile": "098999997"
  }
]'
```

* Thông tin khách hàng

| Key             | Type                          | Description                                                                                             |
| --------------- | ----------------------------- | ------------------------------------------------------------------------------------------------------- |
| name            | string $$^{{\color{red}\*}}$$ | Tên khách hàng                                                                                          |
| mobile          | string $$^{{\color{red}\*}}$$ | Số điện thoại khách hàng                                                                                |
| type            | int                           | <p>Loại khách hàng. 1 = Khách lẻ (default),<br>2 = Khách buôn</p>                                       |
| address         | string                        | Địa chỉ khách hàng                                                                                      |
| gender          | int                           | <p>Giới tính khách hàng. 1 = Nam<br>2 = Nữ</p>                                                          |
| birthday        | date                          | Sinh nhật khách hàng (Định dạng Y-m-d)                                                                  |
| locations       | array                         | Mảng thông tin: Thành phố, quận huyện, phường xã. [Xem bên dưới](#location-param)                       |
| email           | string                        | Email khách hàng                                                                                        |
| pid             | string                        | Số căn cước công dân                                                                                    |
| groupId         | int                           | ID nhóm khách hàng trên Nhanh.vn                                                                        |
| tagIds          | array\[]                      | [Mảng ID nhãn khách hàng](/v3/customer/tags.md)                                                         |
| points          | int                           | Điểm tích lũy của khách hàng                                                                            |
| taxCode         | string                        | Mã số thuế                                                                                              |
| businessName    | string                        | Tên công ty                                                                                             |
| businessAddress | string                        | Địa chỉ công ty                                                                                         |
| description     | string                        | Mô tả                                                                                                   |
| facebookLink    | string                        | Facebook link                                                                                           |
| fromCustomer    | string                        | Số điện thoại khách hàng giới thiệu (khách hàng đã tồn tại trên hệ thống Nhanh.vn)                      |
| saleName        | string                        | Nhân viên phụ trách (username/email của nhân viên thuộc doanh nghiệp đã tồn tại trên hệ thống Nhanh.vn) |

### Locations param

| Key        | Type | Description                                                     |
| ---------- | ---- | --------------------------------------------------------------- |
| cityId     | int  | ID thành phố (Lấy từ [API location](/v3/shipping/location.md))  |
| districtId | int  | ID quận huyện (Lấy từ [API location](/v3/shipping/location.md)) |
| wardId     | int  | ID phường xã (Lấy từ [API location](/v3/shipping/location.md))  |

## Response

* Xem cấu trúc chung [tại đây](/v3/readme.md#response).

### Failed response

* Xem các mã lỗi chung [tại đây](/v3/readme.md#failed-response).

### Successful response

```json
{
  "code": 1,
  "data": [
    {
      "id": "(int) ID khách hàng 1",
      "mobile": "(string) Số điện thoại khách hàng"
    },
    {
      "id": "(int) ID khách hàng 2",
      "mobile": "(string) Số điện thoại khách hàng"
    }
  ]
}
```


---

# 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://apidocs.nhanh.vn/v3/customer/add.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.
