# Thêm chương trình coupon

* Tính năng này được sử dụng để tạo chương trình mã giảm giá.

## Request

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

```curl
curl --location 'https://pos.open.nhanh.vn/v3.0/promotion/batchadd?appId={{appId}}&businessId={{businessId}}' \
--header 'Authorization: {{accessToken}}' \
--header 'Content-Type: application/json'
--data '{
    "name": "Chương trình giảm giá 1",
    "status": 1,
    "startDate": "2025-07-01",
    "endDate": "2025-12-31",
    "codeLength": 5,
    "numberOfCodes": 100,
    "canUsedTimes": 10,
    "valueType": 1,
    "value": 10000
}'
```

### Thông tin tạo chương trình coupon

| Key                           | Type                               | Description                                                             |
| ----------------------------- | ---------------------------------- | ----------------------------------------------------------------------- |
| name                          | string(255) $$^{{\color{red}\*}}$$ | Tên chương trình coupon                                                 |
| status                        | int $$^{{\color{red}\*}}$$         | Trạng thái: 1 - Active, 2 - Inactive                                    |
| startDate                     | string $$^{{\color{red}\*}}$$      | Định dạng: Y-m-d. Ngày áp dụng từ, định dạng Y-m-d                      |
| endDate                       | string $$^{{\color{red}\*}}$$      | Định dạng: Y-m-d. Ngày áp dụng đến, định dạng Y-m-d                     |
| codeLength                    | int $$^{{\color{red}\*}}$$         | Độ dài mã coupon, độ dài sẽ bằng số ký tự, vd: 5 = 5 kí tự, 6 = 6 kí tự |
| numberOfCodes                 | int $$^{{\color{red}\*}}$$         | Số lượng mã coupon muốn tạo (Tối đa 20.000 mã)                          |
| canUsedTimes                  | int $$^{{\color{red}\*}}$$         | Số lần sử dụng của từng mã                                              |
| valueType                     | int $$^{{\color{red}\*}}$$         | <p>Kiểu giảm giá<br>1 = Tiền mặt<br>2 = Chiết khấu</p>                  |
| value                         | int $$^{{\color{red}\*}}$$         | Giá trị coupon                                                          |
| depotIds                      | int or array                       | ID hoặc mảng ID kho được áp dụng mã coupon                              |
| categoryIds                   | int or array                       | ID hoặc mảng ID doanh mục được áp dụng mã coupon                        |
| fromValue                     | int                                | Áp dụng cho hóa đơn có tổng tiền từ                                     |
| toValue                       | int                                | Áp dụng cho hóa đơn có tổng tiền đến                                    |
| prefix                        | string(5)                          | Kí tự thêm vào trước mã coupon                                          |
| suffix                        | string(5)                          | Kí tự thêm vào sau mã coupon                                            |
| valueMax                      | int                                | Giá trị giảm giá tối đa                                                 |
| description                   | string(255)                        | Mô tả                                                                   |
| notApplyWithDiscountPromotion | int                                | Không áp dụng cùng chương trình chiết khấu. Giá trị truyền lên: 1       |

## 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 chương trình coupon"
  }
}
```


---

# 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/promotion/batchadd.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.
