# Tags API

<Aside type="note">
หากต้องการตั้งค่า tag สำหรับ HWID และ UserID ให้ใช้เมธอด [/setTags](/th/developer/api-reference/device-api#settags) จาก Device API
</Aside>

## addTag

`POST` `https://api.pushwoosh.com/json/1.3/addTag`

สร้าง tag ในบัญชีของคุณ

#### Request body

| ชื่อ                                       | ประเภท    | คำอธิบาย                                                                                              |
| ------------------------------------------ | ------- | -------------------------------------------------------------------------------------------------------- |
| auth\*     | string  | [API access token](/th/developer/api-reference/api-identifiers/#api-access-token) จาก Pushwoosh Control Panel                                                           |
| tag\*      | object  | พารามิเตอร์ของ Tag                                                                                          |
| tag.name\* | string  | ชื่อ Tag                                                                                                |
| tag.type\* | integer | ประเภทของ Tag ดูค่าที่เป็นไปได้ด้านล่าง                                                                     |
| tag.user\_specific | boolean | เมื่อเป็น `true` ค่า tag จะถูกจัดเก็บในระดับผู้ใช้และแชร์ไปยังอุปกรณ์ทั้งหมดของผู้ใช้เมื่อตั้งค่าโดย UserID เมื่อเป็น `false` (ค่าเริ่มต้น) tag จะเป็นระดับอุปกรณ์และตั้งค่าต่อ HWID |

<Tabs>
<TabItem label="200">
```json
{
  "status_code": 200,
  "status_message": "OK",
  "response": {
    "result": true
  }
}
```
</TabItem>
</Tabs>



```json title="ตัวอย่าง"
{
  "request": {
    "auth": "yxoPUlwqm…………pIyEX4H", // จำเป็นต้องมี API access token จาก Pushwoosh Control Panel
    "tag": {
      "name": "TAG_NAME",           // จำเป็นต้องมี
      "type": 1,                    // จำเป็นต้องมี ดูค่าที่เป็นไปได้ด้านล่าง
      "user_specific": false        // ไม่จำเป็น true = tag ระดับผู้ใช้ (แชร์ไปยังอุปกรณ์ทั้งหมด); false = tag ระดับอุปกรณ์ (ค่าเริ่มต้น)
    }
  }
}
```

**ประเภทค่า tag ที่เป็นไปได้:**

* 1 - Integer (จำนวนเต็ม)
* 2 - String (ข้อความ)
* 3 - List (รายการ)
* 4 - Date (วันที่)
* 5 - Boolean (ค่าตรรกะ)
* 6 - Decimal (ทศนิยม) เช่น: 19.95
* 7 - Version (เวอร์ชัน) เช่น: "1.0.0.0"



## deleteTag

`POST` `https://api.pushwoosh.com/json/1.3/deleteTag`

ลบ tag พร้อมข้อมูลที่เกี่ยวข้องทั้งหมดออกจากฐานข้อมูลอย่างสมบูรณ์

#### Request body

| ชื่อ                                       | ประเภท   | คำอธิบาย                                    |
| ------------------------------------------ | ------ | ---------------------------------------------- |
| auth\*     | string | [API access token](/th/developer/api-reference/api-identifiers/#api-access-token) จาก Pushwoosh Control Panel |
| tag\*      | object | พารามิเตอร์ของ Tag                                |
| tag.name\* | string | ชื่อของ [tag](/th/developer/api-reference/api-identifiers/#tag) ที่จะลบ                       |

<Tabs>
<TabItem label="200">
```json
{
  "status_code": 200,
  "status_message": "OK",
  "response": {
    "result": true
  }
}
```
</TabItem>
</Tabs>



```json title="ตัวอย่าง"
{
  "request": {
    "auth": "yxoPUlwqm…………pIyEX4H", // จำเป็นต้องมี API access token จาก Pushwoosh Control Panel
    "tag": {
      "name": "TAG_NAME"            // จำเป็นต้องมี ชื่อของ tag ที่จะลบ
    }
  }
}


```

## listTags

`POST` `https://api.pushwoosh.com/json/1.3/listTags`

ดึงรายการ tags ในบัญชี

#### Request body

| ชื่อ                                   | ประเภท   | คำอธิบาย                                    |
| -------------------------------------- | ------ | ---------------------------------------------- |
| auth\* | string | [API access token](/th/developer/api-reference/api-identifiers/#api-access-token) จาก Pushwoosh Control Panel |

<Tabs>
<TabItem label="200">
```json
{
  "status_code": 200,
  "status_message": "OK", 
  "response": {
    "tags": [{
      "name":"Language",
      "type":2
    }, {
      "name":"List tag",
      "type":3
    }]
  }
}
```
</TabItem>
</Tabs>



```json title="ตัวอย่าง"
{
  "request":{
    "auth": "yxoPUlwqm…………pIyEX4H" // API access token จาก Pushwoosh Control Panel
  }
} 
```

**ประเภทของ Tag**:

* 1 - Integer (จำนวนเต็ม)
* 2 - String (ข้อความ)
* 3 - List (รายการ)
* 4 - Date (วันที่)
* 5 - Boolean (ค่าตรรกะ)
* 6 - Decimal (ทศนิยม) เช่น: 19.95
* 7 - Version (เวอร์ชัน) เช่น: "1.0.0.0"