# Promotion

> Base URL: `https://pos.pages.fm/api/v1`. Authenticate with the `api_key` query parameter.

## Get promotion product list

`GET /shops/{SHOP_ID}/promotion_advance`

Get list of promotions

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `SHOP_ID` | path | integer | yes | Shop ID |
| `page` | query | integer |  | Page number |
| `page_size` | query | integer |  | Page size |
| `textSearch` | query | string |  | Text search |

### Responses

- `200` Success (object)

```json
{
  "success": true,
  "data": [
    {
      "id": "260a0d45-ba88-457b-8b31-afa3fda0ce0e",
      "display_id": 50,
      "name": "km 345",
      "type": "discount_by_product",
      "start_time": "2022-03-10T05:04:11Z",
      "end_time": "2022-03-11T05:04:13Z",
      "warehouse_ids": [],
      "customer_tags": [],
      "order_sources": [],
      "group_name": "Nhóm 1",
      "is_activated": true,
      "is_variation": true,
      "is_used": null,
      "is_free_shipping": false,
      "is_discount_in_birthday_customer": false,
      "coupon_info": {
        "discount": 0,
        "is_percent": false
      },
      "promo_code_info": {
        "discount": 0,
        "is_percent": false,
        "max_discount_by_percent": 0
      },
      "discount_by_quantity": 1,
      "items": [
        {
          "id": "bd11e48a-6fec-4e3a-a1b7-8ef834a98dae",
          "promotion_advance_id": "260a0d45-ba88-457b-8b31-afa3fda0ce0e",
          "shop_id": 3,
          "product_id": null,
          "variation_id": "2f3aea54-5c0c-44db-9f9b-2c987c298795",
          "category_id": null,
          "product": null,
          "variation": {
            "id": "2f3aea54-5c0c-44db-9f9b-2c987c298795",
            "display_id": "SB21-M-DEN",
            "product_id": "d6d13d0b-320e-4651-a368-de2c9e30ae66",
            "retail_price": 250000,
            "retail_price_after_discount": 238000
          },
          "level_info": [
            {
              "discount": 30000,
              "is_percent": false,
              "from_quantity": 1,
              "to_quantity": 4
            }
          ],
          "fixed_prices": 0,
          "coupon_item_info": {
            "discount": 0,
            "is_percent": false
          },
          "limited_quantity": 0,
          "limited_quantity_used": 0,
          "attachment_product_info": [],
          "discount_info_by_attachment_product": null
        }
      ],
      "bonus_items": [],
      "total_quantity_bonus": 0,
      "arr_level_promotion": [],
      "level_order_prices": [],
      "priority_level": null,
      "type_employee": "all",
      "post_ids": [],
      "shop_id": 3,
      "creator_id": "4eab0efc-2994-4b96-acf0-e4c847668555",
      "inserted_at": "2022-03-10T05:04:33Z",
      "updated_at": "2022-04-08T08:14:58Z"
    }
  ]
}
```

## Create promotion product

`POST /shops/{SHOP_ID}/promotion_advance`

Create promotion

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `SHOP_ID` | path | integer | yes | Shop ID |

### Request body

Request body containing promotion information to create

- `promotion_advance` (object, required): 
  - `name` (string, required): Promotion name
  - `start_time` (integer): Start time
  - `end_time` (integer): End time
  - `warehouse_ids` (string[]): Warehouse IDs
  - `customer_tags` (string[]): Customer tags
  - `order_sources` (object[]): Order sources
  - `type` (string, required): Promotion type Values: `discount_by_product`, `discount_by_order_price`, `fixed_prices`, `coupon`, `double_reward_point`, `discount_by_coupon_id`, `discount_by_attachment_products`.
  - `group_name` (string): Promotion group
  - `is_activated` (boolean): Is activated
  - `is_variation` (boolean): Is variation
  - `coupon_info` (object): Coupon information
  - `promo_code_info` (object): Promotion code information
  - `items` (object[]): Promotion items
  - `is_free_shipping` (boolean): Is free shipping
  - `discount_by_quantity` (integer): Discount by quantity
  - `bonus_items` (object[]): Bonus items
  - `is_discount_in_birthday_customer` (boolean): Is discount in birthday customer
  - `arr_level_promotion` (object[]): Level promotion array
  - `total_quantity_bonus` (integer): Total quantity bonus
  - `priority_level` (integer): Priority level
  - `type_employee` (string): Type employee
  - `free_products` (object[]): Free products

```json
{
  "promotion_advance": {
    "name": "string",
    "type": "discount_by_product"
  }
}
```

### Responses

- `200` Success (object)

```json
{
  "success": true
}
```

## Update promotion product

`PUT /shops/{SHOP_ID}/promotion_advance/{PROMOTION_ID}`

Update promotion

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `SHOP_ID` | path | integer | yes | Shop ID |
| `PROMOTION_ID` | path | string | yes | Promotion ID |

### Request body

Request body containing promotion information to update

- `promotion_advance` (Promotion, required): 
  - `id` (string): Promotion ID
  - `display_id` (string): Promotion display ID
  - `name` (string): Promotion name
  - `type` (string): Promotion type
  - `start_time` (string (date-time)): Start time
  - `end_time` (string (date-time)): End time
  - `warehouse_ids` (string[]): Warehouse IDs
  - `customer_tags` (string[]): Customer tags
  - `order_sources` (object[]): Order sources
  - `group_name` (string): Promotion group
  - `is_activated` (boolean): Is activated
  - `is_variation` (boolean): Is variation
  - `is_used` (boolean): Is used
  - `is_free_shipping` (boolean): Is free shipping
  - `is_discount_in_birthday_customer` (boolean): Is discount in birthday customer
  - `coupon_info` (object): Coupon information
  - `promo_code_info` (object): Promotion code information
  - `discount_by_quantity` (integer): Discount by quantity
  - `items` (object[]): List of promotion items (products/variations the promotion applies to)
  - `bonus_items` (object[]): Bonus items
  - `total_quantity_bonus` (integer): Total quantity bonus
  - `arr_level_promotion` (object[]): Level promotion array
  - `level_order_prices` (object[]): Level order prices
  - `priority_level` (integer): Priority level
  - `type_employee` (string): Type employee
  - `post_ids` (string[]): Post IDs
  - `shop_id` (integer): Shop ID
  - `creator_id` (string): Creator ID
  - `inserted_at` (string (date-time)): Inserted at
  - `updated_at` (string (date-time)): Updated at

```json
{
  "promotion_advance": {
    "id": "string",
    "display_id": "string",
    "name": "string",
    "type": "string",
    "start_time": "2026-01-01T00:00:00Z",
    "end_time": "2026-01-01T00:00:00Z"
  }
}
```

### Responses

- `200` Success (object)

```json
{
  "success": true
}
```

## Activate/Deactivate/Delete promotions

`POST /shops/{SHOP_ID}/promotion_advance/delete_multi`

Activate, deactivate or delete multiple promotions

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `SHOP_ID` | path | integer | yes | Shop ID |

### Request body

Request body containing promotion IDs to delete

- `ids` (string[], required): Promotion IDs
- `type_action` (string, required): Action type Values: `DEACTIVE_PROMOTIONS` Deactivate promotions, `ACTIVE_PROMOTIONS` Activate promotions, `DELETE_PROMOTIONS` Delete promotions.

```json
{
  "ids": [
    "0fe988a1-26a5-4772-b4b6-a9c17c9f40cd"
  ],
  "type_action": "DEACTIVE_PROMOTIONS"
}
```

### Responses

- `200` Success (object)

```json
{
  "success": true
}
```
