# Cập nhật trạng thái sử dụng coupon

* Tính năng này dùng để cập nhật trạng thái đã sử dụng coupon
  * act = giveaway: Dùng để tặng mã coupon cho khách hàng xong, thì cần báo để server cập nhật lại số lần đã tặng, tránh việc 1 mã được tặng nhiều lần và khách khác không thể sử dụng được nữa.
  * act = used: Dùng để thông báo cho server biết 1 mã coupon đã được sử dụng, tránh việc 1 mã được sử dụng nhiều lần.

## Request

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

```curl
curl --location 'https://pos.open.nhanh.vn/v3.0/promotion/couponupdate?appId={{appId}}&businessId={{businessId}}' \
--header 'Authorization: {{accessToken}}' \
--header 'Content-Type: application/json'
--data '{
    "act": "giveaway",
    "code": "A1BHCUH"
}'
```

### Thông tin tặng hoặc sử dụng mã coupon

| Key  | Type                          | Description                                                |
| ---- | ----------------------------- | ---------------------------------------------------------- |
| act  | string $$^{{\color{red}\*}}$$ | <p>Hành động:<br>giveaway: Tặng mã<br>used: Sử dụng mã</p> |
| code | string $$^{{\color{red}\*}}$$ | Mã giảm giá                                                |

## 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": {
    "depotId": "(int) ID kho hàng",
    "code": "(string) Mã giảm giá",
    "value": "(int) Giá trị",
    "valueMax": "(int) Giá trị tối đa được giảm",
    "valueType": "(int) Loại giảm giá (1= Tiền mặt, 2= Phần trăm)",
    "status": "(int) trạng thái (1 = Active, 2 = Inactive)",
    "usedAt": "(int) Thời gian đã sử dụng mã giảm giá",
    "totalCanUsed": "(int) Tổng số lần có thể sử dụng",
    "totalAssigned": "(int) Tổng số lần đã tặng",
    "totalUsed": "(int) Tổng số lần đã sử dụng",
    "createdAt": "(int) Thời gian tạo"
  }
}
```


---

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