> For the complete documentation index, see [llms.txt](https://help.firstline.cc/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.firstline.cc/developer/api/contact-tag.md).

# 客戶標籤

## 搜尋

```javascript
GET https://{API_DOMAIN}/api/v1/contact-tag
```

```javascript
curl -X GET
    -H "Content-Type: application/json"
    '{"name": "vip"}'
    https://{API_HOST}/api/v1/contact-tag
```

### Form Data

下表為可使用的過濾條件

| PARAMETER | REQUIRED | DEFAULT | TYPE   | DESCRIPTION |
| --------- | -------- | ------- | ------ | ----------- |
| **name**  | false    | NULL    | String | 模糊搜尋標籤名稱    |

### Response

| PROPERTY | TYPE             | DESCRIPTION     |
| -------- | ---------------- | --------------- |
| **data** | Array of objects | 客戶標籤資料陣列        |
| **meta** | Object           | Pagination meta |

```javascript
{
    "data": [
        {
            "id": 1,
            "name": "高消費",
            "description": null,
            "contacts_count": 1
        },
        {
            "id": 2,
            "name": "已婚",
            "description": null,
            "contacts_count": 5
        }
    ],
    "links": {
        "first": "http://dev.dev.firstline.cc/api/v1/contact-tag?page=1",
        "last": "http://dev.dev.firstline.cc/api/v1/contact-tag?page=2",
        "prev": null,
        "next": "http://dev.dev.firstline.cc/api/v1/contact-tag?page=2"
    },
    "meta": {
        "current_page": 1,
        "from": 1,
        "last_page": 2,
        "links": [
            {
                "url": null,
                "label": "&laquo; Previous",
                "active": false
            },
            {
                "url": "http://dev.dev.firstline.cc/api/v1/contact-tag?page=1",
                "label": "1",
                "active": true
            },
            {
                "url": "http://dev.dev.firstline.cc/api/v1/contact-tag?page=2",
                "label": "2",
                "active": false
            },
            {
                "url": "http://dev.dev.firstline.cc/api/v1/contact-tag?page=2",
                "label": "Next &raquo;",
                "active": false
            }
        ],
        "path": "http://dev.dev.firstline.cc/api/v1/contact-tag",
        "per_page": 15,
        "to": 15,
        "total": 30
    }
}
```

## 取得單筆資料

```javascript
GET https://{API_DOMAIN}/api/v1/contact-tag/{id}
```

```javascript
curl -X GET
    -H "Content-Type: application/json"
    https://{API_HOST}/api/v1/contact-tag/1
```

### URL Parameters

| PARAMETER            | REQUIRED | DEFAULT | TYPE   | DESCRIPTION |
| -------------------- | -------- | ------- | ------ | ----------- |
| **contact\_tag\_id** | true     | NULL    | Number | 客戶標籤系統 ID   |

### Response

| PROPERTY | TYPE   | DESCRIPTION |
| -------- | ------ | ----------- |
| **data** | Object | 客戶標籤        |

```javascript
{
    "data": {
        "id": 1,
        //標籤名稱
        "name": "高消費",
        //標籤描述
        "description": null,
        //擁有此標籤客戶數
        "contacts_count": 1
    }
}
```

## 新增

```javascript
POST https://{API_DOMAIN}/api/v1/contact-tag
```

```javascript
    '{"name": "高級會員", "description": "年繳" }'
    https://{API_HOST}/api/v1/contact-tag
```

### Form Data

| PARAMETER       | REQUIRED | DEFAULT | TYPE   | DESCRIPTION |
| --------------- | -------- | ------- | ------ | ----------- |
| **name**        | true     | NULL    | String | 標籤名稱        |
| **description** | false    | NULL    | String | 標籤描述        |

> 回傳 json 格式

```javascript
{
    "data": {
        "id": 1,
        "name": "高級會員",
        "description": "年繳會員",
        "contacts_count": 0
    }
}
```

## 更新

```javascript
PUT https://{API_DOMAIN}/api/v1/contact-tag/{id}
```

```javascript
curl -X PUT
    -H "Content-Type: application/json"
    '{"name": "月費會員" }'
    https://{API_HOST}/api/v1/contact-tag/1
```

### URL Parameters

| PARAMETER       | REQUIRED | DEFAULT | TYPE   | DESCRIPTION |
| --------------- | -------- | ------- | ------ | ----------- |
| **name**        | true     | null    | String | 標籤名稱        |
| **description** | false    | null    | String | 標籤名數        |

### Response

```javascript
{
    "data": {
        "id": 1,
        "name": "高消費",
        "description": null,
        "contacts_count": 1
    }
}
```

## 刪除

```
DELETE https://{API_HOST}/api/v1/contact-tag/{id}
```

### URL Parameters

| PARAMETER | DESCRIPTION    |
| --------- | -------------- |
| **id**    | 客戶標籤的系統編號  #ID |

```javascript
curl -X DELETE
    -H "Content-Type: application/json"
    https://{API_HOST}/api/v1/contact-tag/22
```

## 通用資料
