# Thêm khách hàng

* /api/customer/add: Tính năng này dùng để thêm và sửa thông tin khách hàng. Hệ thống dùng trường mobile làm key, nếu chưa tồn tại thì sẽ thêm mới khách hàng, nếu tồn tại rồi thì sẽ cập nhật thông tin khách hàng.
* Tối đa mỗi lần không quá 50 khách hàng.

## Request

* Xem các [common request params](/v2/readme.md#request-params)
* Các key của mảng **data array** dùng để tạo **data** json string:

  ```javascript
  // each request can send maximum 50 customers
  [
    [ // customer 1 ], // see the structure in the table below
    [ // customer  2 ],
    ...
  ]
  ```

| Key          | Type                          | Description                                                                                             |
| ------------ | ----------------------------- | ------------------------------------------------------------------------------------------------------- |
| 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) |
| name         | string $$^{{\color{red}\*}}$$ | Tên khách hàng                                                                                          |
| type         | int                           | 1 - Khách lẻ, 2 - Khách buôn                                                                            |
| address      | string                        | địa chỉ khách hàng                                                                                      |
| mobile       | string $$^{{\color{red}\*}}$$ | Số điện thoại khách hàng                                                                                |
| businessName | string                        | Tên công ty                                                                                             |
| taxCode      | string                        | Mã số thuế                                                                                              |
| points       | int                           | điểm tích lũy của khách hàng                                                                            |
| gender       | int                           | 1 - Nam, 2 - Nữ                                                                                         |
| birthday     | date                          | Sinh nhật khách hàng (ngày/tháng/năm)                                                                   |
| cityName     | string                        | Tên thành phố (Lấy từ [/api/shipping/location](/v2/shipping/location.md))                               |
| districtName | string                        | Tên quận huyện (Lấy từ [/api/shipping/location](/v2/shipping/location.md))                              |
| wardName     | string                        | Tên phường xã (Lấy từ [/api/shipping/location](/v2/shipping/location.md))                               |
| email        | string                        | Email khách hàng                                                                                        |
| pid          | string                        | Số CMND                                                                                                 |
| description  | string                        | Mô tả                                                                                                   |
| facebookLink | string                        | Facebook link                                                                                           |
| groupId      | int                           | ID nhóm khách hàng trên Nhanh.vn                                                                        |


---

# 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/v2/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.
