# Order tag

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

## List of order tags

`GET /shops/{SHOP_ID}/orders/tags`

Get list of order tags

### Parameters

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

### Responses

- `200` Success (object)

```json
{
  "data": [
    {
      "id": 75,
      "name": "thẻ 4",
      "color": "#123123",
      "is_system_tag": false,
      "groups": [
        {
          "id": 13,
          "name": "nhom 1"
        },
        {
          "id": 16,
          "name": "nhom 2"
        }
      ]
    },
    {
      "id": 1,
      "name": "Giao không thành",
      "color": "#f04134",
      "is_system_tag": true,
      "groups": [
        {
          "id": -1,
          "name": "Delivery Group"
        },
        {
          "id": 13,
          "name": "nhom 1"
        }
      ]
    },
    {
      "id": 2,
      "name": "Chờ cọc",
      "color": "#096dd9",
      "is_system_tag": true,
      "groups": []
    }
  ],
  "success": true
}
```

## Create order tag

`POST /shops/{SHOP_ID}/orders/tags`

Create a new order tag

### Parameters

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

### Request body

Request body containing order tag information to create

- `name` (string, required): Tag name
- `tag_color` (string): Tag color code
- `groups` (integer[]): List of tag group IDs. Get by API GET /shops/{SHOP_ID}/orders/tag_groups
- `statuses` (integer[]): List of order statuses to apply the tag

```json
{
  "name": "test 5.1",
  "tag_color": "#000",
  "groups": [
    1
  ],
  "statuses": [
    1,
    2,
    3
  ]
}
```

### Responses

- `200` Success (object)

```json
{
  "data": {
    "id": 50,
    "name": "test 5.1",
    "tag_color": "#000",
    "groups": [
      1
    ],
    "statuses": [
      1,
      2,
      3
    ]
  },
  "success": true
}
```

## Update order tag

`PUT /shops/{SHOP_ID}/orders/tags/{TAG_ID}`

Update an order tag. Only applies to tags that are not system tags (is_system_tag = false)

### Parameters

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

### Request body

Request body containing order tag information to update

- `name` (string, required): Tag name
- `tag_color` (string): Tag color code
- `groups` (integer[]): List of tag group IDs. Get by API GET /shops/{SHOP_ID}/orders/tag_groups
- `statuses` (integer[]): List of order statuses to apply the tag

```json
{
  "name": "test 4.4",
  "tag_color": "#000",
  "groups": [
    1,
    2
  ],
  "statuses": [
    1,
    2,
    3
  ]
}
```

### Responses

- `200` Success (object)

```json
{
  "data": {
    "id": 45,
    "name": "test 4.4",
    "tag_color": "#000",
    "groups": [
      2,
      1
    ],
    "statuses": [
      1,
      2,
      3
    ]
  },
  "success": true
}
```

## List of order tag groups

`GET /shops/{SHOP_ID}/orders/tag_groups`

Get list of order tag groups

### Parameters

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

### Responses

- `200` Success (object)

```json
{
  "data": [
    {
      "id": 1,
      "name": "nhóm 1",
      "add_multiple_tags": true,
      "tags": [
        41,
        50,
        45
      ]
    }
  ],
  "success": true
}
```
