> For the complete documentation index, see [llms.txt](https://en.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://en.help.firstline.cc/developer/api/knowledge-base.md).

# Knowledge base

## Best Practices

### Update Existing Knowledge Base Article

1. **Search and Locate**
   * Find the target article by using list with search by title or keywords.
   * Ensure only a single record is matched, obtain the `id` information.
2. **Conditional Update**
   * Call the update API (PUT / PATCH) and include the next version identification condition.

## Search

```javascript
GET https://{API_DOMAIN}/api/v1/kb
```

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

### URL Parameters

| Name        | Type    | Required | Description                       | Example           |
| ----------- | ------- | -------- | --------------------------------- | ----------------- |
| `page`      | integer | No       | Page number (starting from 1)     | `page=2`          |
| `search`    | string  | No       | Filter KB name/content by keyword | `search=security` |
| `is_public` | integer | No       | Whether the article is public     | `is_public=1`     |

### Response

| PROPERTY | TYPE             | DESCRIPTION           |
| -------- | ---------------- | --------------------- |
| **data** | Array of objects | Array of article data |
| **meta** | Object           | Meta data for tabs    |

```json
{
    "data": [
    {
        "id": 5,
        "subject": "LINE Rich Menu",
        "content": "<h2>Overview</h2><p>The rich menu is located under the LINE Official Account chat; customers see the rich menu at first glance, .....",
        "like_count": 1,
        "dislike_count": 0,
        "readed_count": 10,
        "is_public": true,
        "hit_count": 0,
        "creater_id": 3,
        "creater":
        {
            "id": 3,
            "name": "eason d",
            "first_name": "eason",
            "last_name": "d",
            "employee_no": "eason",
            "photo_url": null,
            "identity_no": null,
            "job_title_id": -1,
            "department_id": -1,
            "extension_id": -1,
            "profile_id": 6,
            "group_id": null,
            "created_at": "2022-06-25 08:42:44",
            "updated_at": "2025-06-14 10:56:42"
        },
        "sub_category_id": null,
        "sub_category": null,
        "file_entities_count": 0,
        "file_entities": [],
        "category": null,
        "category_id": -1,
        "kb_tags": [],
        "kb_tag_ids": []
    }],
    "links":
    { ...
    },
    "meta":
    { ...
    }
}
```

## Retrieve Single Record

```javascript
GET https://{API_DOMAIN}/api/v1/kb/{kb}
```

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

### URL Parameters

| PARAMETER | REQUIRED | DEFAULT | TYPE   | DESCRIPTION            |
| --------- | -------- | ------- | ------ | ---------------------- |
| **id**    | true     | NULL    | Number | Customer tag system ID |

### Response

| PROPERTY | TYPE   | DESCRIPTION                 |
| -------- | ------ | --------------------------- |
| **data** | Object | Knowledge base article data |

```json
{
    "data":
    {
        "id": 5,
        "subject": "LINE Rich Menu",
        "content": "<h2>Overview</h2><p>The rich menu is located under the LINE Official Account chat; customers see the rich menu at first glance, .....",
        "like_count": 1,
        "dislike_count": 0,
        "readed_count": 10,
        "is_public": true,
        "hit_count": 0,
        "creater_id": 3,
        "creater":
        {
            "id": 3,
            "name": "eason d",
            "first_name": "eason",
            "last_name": "d",
            "employee_no": "eason",
            "photo_url": null,
            "identity_no": null,
            "job_title_id": -1,
            "department_id": -1,
            "extension_id": -1,
            "profile_id": 6,
            "group_id": null,
            "created_at": "2022-06-25 08:42:44",
            "updated_at": "2025-06-14 10:56:42"
        },
        "sub_category_id": null,
        "sub_category": null,
        "file_entities_count": 0,
        "file_entities": [],
        "category": null,
        "category_id": -1,
        "kb_tags": [],
        "kb_tag_ids": []
    }
}
```

## Create

```javascript
POST https://{API_DOMAIN}/api/v1/kb
```

```javascript
curl -X POST
    -H "Content-Type: application/json"
    '{"subject": "How to Configure Product", "content": "About the product...." }'
    https://{API_HOST}/api/v1/kb
```

### Form Data

| Name        | Type    | Required | Description                   | Example                      |
| ----------- | ------- | -------- | ----------------------------- | ---------------------------- |
| `subject`   | string  | Yes      | Article title                 | `"How to Configure Product"` |
| `content`   | string  | Yes      | Article content               | `"About the product...."`    |
| `is_public` | boolean | No       | Whether the article is public | `false`                      |

## Update

```javascript
PUT https://{API_DOMAIN}/api/v1/kb/{kb}
```

```javascript
curl -X PUT
    -H "Content-Type: application/json"
    '{"subject": "How to Configure Product", "content": "About the product...." }'
    https://{API_HOST}/api/v1/kb/36
```
