Knowledge Center API
# Knowledge Center API
# API Declaration
The "token" param must be contained in the header of the https request when calling the API.
Token is the only global API call credential for the Sobot API open platform. It is used when developers call the business APIs and thus should be properly kept. At least 32 chars should be reserved to store token. The validity period of token is currently 24 hours. It needs to be refreshed regularly or reacquired according to the token failure prompt returned by the API. When requesting the token API, regardless of the existence of token, a new token will be returned and its expiry time will be reset (currently 24 hours).
Token usage description:
- Developers need to obtain and manage the token uniformly. When calling the Sobot open APIs of various business, they should use the same token, instead of refreshing and obtaining new tokens for each business. Otherwise, it will easily lead to token invalidation and affect the normal API call.
- The current validity period of the token is transmitted by the returned expire_in, which is currently a value within 86,400 s. Developers need to refresh the new token in advance based on this valid time.
- Developers should reacquire the token according to the token invalidation prompt returned by the API.
# API Call
# ● Get the Access Token Code
API description:
Get the open API token, which is only applicable to all APIs of Sobot Open Platform v5.0. Contact the Sobot after-sales service personnel to get appid and app_key in the API.
Request method: GET
Request URL:
https://sg.sobot.io/api/get_token
Request param:
Param | Type | Required | Description |
---|---|---|---|
appid | String | Yes | API credential ID, the unique API call credential ID for the 3rd-party users |
create_time | String | Yes | Timestamp (s), e.g.: timestamp 1569397773 for 2019-09-25 15:49:33 |
sign | String | Yes | Signature, md5(appid + create_time + app_key) sign signature, app_key is private key |
Return param:
Param | Type | Required | Description |
---|---|---|---|
ret_code | String | Yes | Return code |
ret_msg | String | Yes | Return message |
item | Object | No | Return object |
item object:
Param | Type | Required | Description |
---|---|---|---|
token | String | Yes | token code |
expires_in | String | Yes | Credential valid time Unit: second |
Timestamp conversion tool:
https://www.unixtimestamp.com/
sign signature generation example:
E.g., appid = "1"; create_time="1569397773"; app_key="2"
sign = Md5("115693977732") is 258eec3118705112b2c53dc8043d4d34.
Request example:
curl https://sg.sobot.io/api/get_token?appid=1&create_time=1569397773&sign=258eec3118705112b2c53dc8043d4d34
Return example:
{
"item": {
"token": "4ac37cb2e9c740dba4b75a34d5358802",
"expires_in": "86400"
},
"ret_code": "000000",
"ret_msg": "success"
}
2
3
4
5
6
7
8
# ● Query classification
API type: Active call API
API function: The knowledge classification list can be queried by calling this interface.
Request method: POST
Request URL:
http://sg.sobot.io/ai-agent-open/api/kb/get_type_tree_all
Request example:
curl http://sg.sobot.io/ai-agent-open/api/kb/get_type_tree_all
-X POST
-H 'token:cdc94901834c4190adbde1810d2d3a58'
-H 'content-type: application/json'
-d '{}'
2
3
4
5
Request param:
Name | Type | Required | Description |
---|---|---|---|
kbid | String | No | Knowledge base id |
kbid_list | Array | No | Multiple knowledge base id |
Return param:
Name | Type | Required | Description |
---|---|---|---|
ret_code | String | / | Return code |
ret_msg | String | / | Return message |
data | Object | / | Return object |
data.question_type_tree Object:
Name | Type | Required | Description |
---|---|---|---|
kbid | Integer | / | Knowledge base id |
id | String | / | The knowledge base corresponds to the configId value of the database |
type | String | / | 1- Knowledge Base 2- Question Classification |
is_web | Integer | / | Is it a web knowledge base? 0- not 1-Yes |
scope_flag | Integer | / | All 1 within the visible range 0 |
name | String | / | Knowledge base name |
child_type_list | Array | / | List of subcategory objects |
child_type_list.id | String | / | Classification id |
child_type_list.type | Integer | / | 1- Knowledge Base 2- Question Classification |
child_type_list.sort_no | Integer | / | Sorting field |
child_type_list.question_type_name | String | / | Classification name |
child_type_list.parent_typeid | String | / | Parent classification id |
child_type_list.question_typeid | String | / | Classification id |
Request example:
{
"kbid": 31,
"kbid_list": [31,30]
}
2
3
4
Return example
{
"data": {
"question_type_tree": [
{
"kbid": 32,
"is_web": 0,
"scope_flag": 1,
"name": "Knowledge Base XXX",
"id": "c3dbe5adf8da4d83a15cd3c7305f8e33",
"type": 1,
"child_type_list": [
{
"sort_no": 1,
"question_type_name": "Kind001",
"parent_typeid": "-1",
"child_type_list": [],
"id": "0474764dbd81408b9aaca8d4fce2e271",
"type": 2,
"question_typeid": "0474764dbd81408b9aaca8d4fce2e271"
}
]
}
]
},
"ret_msg": "Operation successful",
"ret_code": "000000"
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# ● Add categories
API type: Active call API
API function: Classifications can be added by calling this interface.
Request method: POST
Request URL:
http://sg.sobot.io/ai-agent-open/api/kb/add_type
Request param:
Name | Type | Required | Description |
---|---|---|---|
kbid | String | Yes | Knowledge base id |
question_type_name | String | Yes | Classification name |
parent_typeid | String | Yes | Parent classification id, top level is -1 |
Return param:
Name | Type | Required | Description |
---|---|---|---|
ret_code | String | / | Return code |
ret_msg | String | / | Return message |
data | Object | / | Return object |
Data object:
Name | Type | Required | Description |
---|---|---|---|
kbid | Integer | / | Knowledge base id |
update_serviceid | String | / | Updater id |
create_time | Long | / | Creation time |
question_type_desc | String | / | Question type description |
create_serviceid | String | / | Creator id |
parent_typeid | String | / | Parent id |
type_level | Integer | / | Classification level, 0 root directory, 1 first level classification, 2 second level classification |
question_typeid | String | / | Question type id |
sort_no | Integer | / | Sort |
update_time | String | / | Update time |
companyid | String | / | Company id |
question_type_name | String | / | Question type name |
update_service_name | String | / | Updater name |
create_service_name | String | / | Creator name |
question_type_status | String | / | Question type status: 0 deleted (invalid), 1 valid |
type_flag | Integer | / | Type flag: 1-ordinary classification; 2-multi-turn conversation flag; 3-outbound question 4-internal knowledge base classification |
Request example:
curl http://sg.sobot.io/ai-agent-open/api/kb/add_type
-X POST
-H 'token:cdc94901834c4190adbde1810d2d3a58'
-H 'content-type: application/json'
-d '
{
"kbid": 32,
"question_type_name": "My category",
"parent_typeid": "-1"
}'
2
3
4
5
6
7
8
9
10
Return example
{
"data": {
"kbid": 32,
"update_serviceid": "6a2fce77ad1a4051bf74254cf9c3c393",
"create_time": 1753782482,
"question_type_desc": "First level classification",
"create_serviceid": "6a2fce77ad1a4051bf74254cf9c3c393",
"parent_typeid": "-1",
"type_level": 1,
"question_typeid": "3208bf814aa240ffb8690dda12192513",
"sort_no": 13,
"update_time": 1753782482073,
"companyid": "039fe9e7e2e24f8b8685f4ce5edef3e2",
"question_type_name": "My category",
"update_service_name": "Super Admin",
"create_service_name": "Super Admin",
"question_type_status": 1,
"type_flag": 4
},
"ret_msg": "Operation successful",
"ret_code": "000000"
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# ● Modify classification
API type: Active call API
API function: Classifications can be modified by calling this interface.
Request method: POST
Request URL:
http://sg.sobot.io/ai-agent-open/api/kb/edit_type
Request param:
Name | Type | Required | Description |
---|---|---|---|
kbid | String | Yes | Knowledge base id |
question_typeid | String | Yes | Classification id |
question_type_name | String | Yes | Classification name |
parent_typeid | String | Yes | Parent classification id, top level is -1 |
Return param:
Name | Type | Required | Description |
---|---|---|---|
ret_code | String | / | Return code |
ret_msg | String | / | Return message |
Request example:
curl http://sg.sobot.io/ai-agent-open/api/kb/edit_type
-X POST
-H 'token:cdc94901834c4190adbde1810d2d3a58'
-H 'content-type: application/json'
-d '
{
"kbid": 32,
"question_typeid": "f43c8ff96c224b329eee1013ecc770d0",
"question_typeName": "My category1",
"parent_typeid": "-1"
}'
2
3
4
5
6
7
8
9
10
11
Return example
{
"ret_msg": "Operation successful",
"ret_code": "000000"
}
2
3
4
# ● Delete classification
API type: Active call API
API function: Classifications can be deleted by calling this interface.
Request method:
POST
Request URL:
http://sg.sobot.io/ai-agent-open/api/kb/delete_type
Request param:
Name | Type | Required | Description |
---|---|---|---|
question_typeid | String | Yes | Classification id |
Return param:
Name | Type | Required | Description |
---|---|---|---|
ret_code | String | / | Return code |
ret_msg | String | / | Return message |
Request example:
curl http://sg.sobot.io/ai-agent-open/api/kb/delete_type
-X POST
-H 'token:cdc94901834c4190adbde1810d2d3a58'
-H 'content-type: application/json'
-d '
{
"question_typeid": "9bdf7bff7ea64e1bb4f5e766752dd584"
}'
2
3
4
5
6
7
8
Return example
{
"ret_msg": "Operation successful",
"ret_code": "000000"
}
2
3
4
# ● Query knowledge base list
API type: Active call API
API function: The knowledge base list can be queried by calling this interface.
Request method: POST
Request URL:
http://sg.sobot.io/ai-agent-open/api/kb/query_base_by_operate
Request param:
Name | Type | Required | Description |
---|---|---|---|
page_no | Integer | Yes | Page number |
page_size | Integer | Yes | Number of items |
Return param:
Name | Type | Required | Description |
---|---|---|---|
ret_code | String | / | Return code |
ret_msg | String | / | Return message |
total_count | Integer | / | Number of data items |
page_count | Integer | / | Total pages |
page_no | Integer | / | Page number |
page_size | Integer | / | Number of items per page |
data | Object | / | Return object |
Data object:
Name | Type | Required | Description |
---|---|---|---|
kbid | Integer | / | Knowledge base id |
kb_name | String | / | Knowledge base name |
kb_remark | String | / | Knowledge base remarks |
kb_type | Integer | / | Knowledge base type 1 External knowledge base 2 Internal knowledge base 3 Web knowledge base |
kb_status | String | / | Knowledge base status 0 Normal 1 Invalid |
scope_flag | Integer | / | Visible range 0 Internal 1 All |
organize_str | String | / | Usage scope |
service_auth_type | Integer | / | Operation personnel permission type 1-Management permission 2-Edit permission |
question_num | Integer | / | Number of questions |
companyid | String | / | Company id |
configid | String | / | Knowledge base configuration id |
operation_str | String | / | Operation personnel |
update_serviceid | String | / | Updater id |
update_time | String | / | Update time |
update_service_name | String | / | Updater name |
Request example:
curl http://sg.sobot.io/ai-agent-open/api/kb/query_base_by_operate
-X POST
-H 'token:cdc94901834c4190adbde1810d2d3a58'
-H 'content-type: application/json'
-d '
{
"page_no": 1,
"page_size": 2
}'
2
3
4
5
6
7
8
9
Return example
{
"data": [
{
"kbid": 33,
"kb_remark": "Record all after-sales issues",
"update_serviceid": "6a2fce77ad1a4051bf74254cf9c3c393",
"scope_flag": 1,
"kb_type": 2,
"organize_str": "All visible",
"service_auth_type": 1,
"question_num": 5,
"kb_name": "After-sales Issue Knowledge Base",
"kb_status": "0",
"update_time": 1751013009400,
"companyid": "039fe9e7e2e24f8b8685f4ce5edef3e2",
"configid": "a319738530a644dc854e6f7b79ec0232",
"operation_str": "HonLia",
"update_service_name": "HonLia"
},
{
"kbid": 32,
"kb_remark": "Verification",
"update_serviceid": "6a2fce77ad1a4051bf74254cf9c3c393",
"scope_flag": 1,
"kb_type": 2,
"organize_str": "All visible",
"service_auth_type": 1,
"question_num": 7,
"kb_name": "Knowledge Base Verification 2",
"kb_status": "0",
"update_time": 1725348000066,
"companyid": "039fe9e7e2e24f8b8685f4ce5edef3e2",
"configid": "c3dbe5adf8da4d83a15cd3c7305f8e33",
"operation_str": "HonLia, Liu Fei",
"update_service_name": "HonLia"
}
],
"total_count": 12,
"page_no": 1,
"ret_msg": "Operation successful",
"ret_code": "000000",
"page_count": 6,
"page_size": 2
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# ● Query knowledge list
API type: Active call API
API function: The knowledge list can be queried by calling this interface.
Request method: POST
Request URL:
http://sg.sobot.io/ai-agent-open/api/kb/query_knowledge_list
Request param:
Name | Type | Required | Description |
---|---|---|---|
page_no | Integer | Yes | Page number |
page_size | Integer | Yes | Number of items |
kb_ids | Array | Yes | Knowledge base id |
question_type_ids | Array | No | Directory ids including subdirectories (when no type is selected, -1 is passed by default) |
key_flag | Integer | No | Query category 1-Title, 2-Content, 3-Full text, 4-Similar questions, 5-URL |
key_words | Array | No | Query keyword content, multiple keywords separated by spaces |
order_type | Integer | No | Sort type 1-Sort by update time, 2-Sort by creation time |
used_flag | Integer | No | Entry status 0-Enabled, 1-Disabled |
language | String | No | Language |
createid | String | No | Creator id |
updateid | String | No | Updater id |
save_type | Integer | No | Knowledge save status 0-Draft, 1-Published |
Return param:
Name | Type | Required | Description |
---|---|---|---|
ret_code | String | / | Return code |
ret_msg | String | / | Return message |
total_count | Integer | / | Number of data items |
page_count | Integer | / | Total pages |
page_no | Integer | / | Page number |
page_size | Integer | / | Number of items per page |
data | Object | / | Return object |
Data.search_list object:
Name | Type | Required | Description |
---|---|---|---|
kbid | Integer | / | Knowledge base id |
save_type | String | / | Save type 1-Published 0-Draft |
timezone | String | / | Time zone |
language | String | / | Language |
doc_type | Integer | / | Knowledge type 1-Article, 2-Question, 3-File |
question_title | String | / | Title |
rule_status | String | / | Rule status |
update_name | String | / | Updater name |
rule_desc_and_list | Array | / | AND rule list description |
rule_desc_or_list | Array | / | OR rule list |
update_time | Long | / | Update time |
companyid | String | / | Company id |
default_lan_flag | String | / | Default language flag 1-Default 0-Non-default |
createid | String | / | Creator id |
sub_doc | Array | / | Existing language entries |
create_time | Long | / | Creation time |
rule_name | String | / | Rule name |
cover | String | / | Cover link |
answer_info | Array | / | Answer content |
file_name | String | / | File name |
docid | String | / | Entry id |
question_typeid | String | / | Directory id |
file_size | Integer | / | File size |
effect_status | Integer | / | Effective status 0-Permanently effective, 1-Custom time |
updateid | String | / | Updater id |
dataid | String | / | Data main id, Used to distinguish a group of multilingual term identifiers |
used_flag | Integer | / | Knowledge status 0-Enabled, 1-Disabled, 2-Initialized |
ruleid | String | / | Rule id |
create_name | String | / | Creator name |
Request example:
curl http://sg.sobot.io/ai-agent-open/api/kb/query_knowledge_list
-X POST
-H 'token:cdc94901834c4190adbde1810d2d3a58'
-H 'content-type: application/json'
-d '
{
"kb_ids": [
32
],
"question_type_ids": [
"f43c8ff96c224b329eee1013ecc770d0",
"776be87dedfa41a28fc92bd9b82cf99a"
],
"language": "zh-Hans",
"order_type": 1,
"used_flag": 0,
"createid": null,
"updateid": null,
"key_flag": 3,
"sub_doc_used_flag": 0,
"save_type": 1,
"page_no": 1,
"page_size": 15
}'
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
Return example
{
"data": {
"search_list": [
{
"kbid": 32,
"save_type": "1",
"timezone": "Asia/Shanghai",
"reset_section_flag": "1",
"language": "zh-Hans",
"doc_type": 3,
"question_title": "test111222222",
"rule_status": "UPDATE",
"update_name": "HonLia",
"rule_desc_and_list": [
"Channel source belongs to Desktop website, All"
],
"update_time": 1753467955670,
"companyid": "039fe9e7e2e24f8b8685f4ce5edef3e2",
"default_lan_flag": 1,
"createid": "6a2fce77ad1a4051bf74254cf9c3c393",
"sub_doc": [],
"create_time": 1751015106277,
"rule_name": "Add a rule",
"answer_info": [
{
"answerid": "9a0a8e992aec41b980035472b7fe1960",
"answer": "https://img-test.sobot.com/039fe9e7e2e24f8b8685f4ce5edef3e2/common/test_1751015095246.pdf",
"answer_txt": "https://img-test.sobot.com/039fe9e7e2e24f8b8685f4ce5edef3e2/common/test_1751015095246.pdf",
"answer_status": 0
}
],
"file_name": "test.pdf",
"docid": "b50d3cf526544e6a8ee5f7cd621b485c",
"batchid": "4f04b920cd8a4fa9b0785f2253f49d5d",
"question_typeid": "776be87dedfa41a28fc92bd9b82cf99a",
"file_size": 89332,
"effect_status": 0,
"updateid": "6a2fce77ad1a4051bf74254cf9c3c393",
"dataid": "90c5ab873afd414da61b8c77e48f9140",
"section_error_case": "",
"used_flag": 0,
"ruleid": "b17f3bf60f0340dcb3d23f657117a32b",
"section_status": "SECTION_SUCCESS",
"create_name": "HonLia"
},
{
"kbid": 32,
"save_type": "1",
"timezone": "Asia/Shanghai",
"reset_section_flag": "1",
"language": "zh-Hans",
"doc_type": 1,
"question_title": "Article title 11",
"rule_status": "ENABLE",
"update_name": "HonLia",
"cover": "https://img-test.sobot.com/039fe9e7e2e24f8b8685f4ce5edef3e2/common/2234_1751012102909.png",
"update_time": 1753467952956,
"companyid": "039fe9e7e2e24f8b8685f4ce5edef3e2",
"default_lan_flag": 1,
"createid": "6a2fce77ad1a4051bf74254cf9c3c393",
"sub_doc": [],
"create_time": 1751012085849,
"answer_info": [
{
"answerid": "5b983abd9d0b461f9c0c59ab62e72360",
"answer": "<h4>The first paragraph of the article, <strong>bold text,</strong> let's add an image 111😛</h4><table style=\"width: auto;\"><tbody><tr><th colSpan=\"1\" rowSpan=\"1\" width=\"auto\">Name</th><th colSpan=\"1\" rowSpan=\"1\" width=\"auto\">Age</th><th colSpan=\"1\" rowSpan=\"1\" width=\"auto\">Gender</th></tr><tr><td colSpan=\"1\" rowSpan=\"1\" width=\"auto\">Zhang San</td><td colSpan=\"1\" rowSpan=\"1\" width=\"auto\">23</td><td colSpan=\"1\" rowSpan=\"1\" width=\"auto\">Male</td></tr></tbody></table><p><br></p>",
"answer_txt": "The first paragraph of the article, bold text, let's add an image 111😛NameAgeGenderZhang San23Male",
"answer_status": 0
}
],
"file_name": "",
"docid": "b8fa250001214b9d90a6c49c450956c4",
"batchid": "4f04b920cd8a4fa9b0785f2253f49d5d",
"question_typeid": "776be87dedfa41a28fc92bd9b82cf99a",
"effect_status": 0,
"updateid": "6a2fce77ad1a4051bf74254cf9c3c393",
"dataid": "1f73a822e9b149b0aa3a0591cce37c24",
"section_error_case": "",
"used_flag": 0,
"ruleid": "ALL",
"section_status": "SECTION_SUCCESS",
"create_name": "HonLia"
},
{
"kbid": 32,
"save_type": "1",
"timezone": "Asia/Shanghai",
"reset_section_flag": "1",
"language": "zh-Hans",
"doc_type": 2,
"question_title": "Knowledge title",
"rule_status": "ENABLE",
"update_name": "HonLia",
"update_time": 1751011276125,
"companyid": "039fe9e7e2e24f8b8685f4ce5edef3e2",
"default_lan_flag": 1,
"createid": "6a2fce77ad1a4051bf74254cf9c3c393",
"sub_doc": [],
"create_time": 1751010704704,
"answer_info": [
{
"answerid": "d1fae55ddc924a4cbc3dcb1abab7fd72",
"answer": "<p>The first paragraph😁content-<strong>let's try an image</strong><img src=\"https://img-test.sobot.com/039fe9e7e2e24f8b8685f4ce5edef3e2/common/3_1751011223673.png\" alt=\"\" data-href=\"\" style=\"\"/></p>",
"answer_txt": "The first paragraph😁content-image try",
"answer_status": 0
}
],
"file_name": "",
"docid": "15a122d0d2a443deb7b0fd65ec8ecc32",
"batchid": "-1",
"question_typeid": "776be87dedfa41a28fc92bd9b82cf99a",
"effect_status": 0,
"updateid": "6a2fce77ad1a4051bf74254cf9c3c393",
"dataid": "50dfcff8fc8248078908c9751346d260",
"used_flag": 0,
"ruleid": "ALL",
"section_status": "SECTION_OLD",
"create_name": "HonLia"
}
]
},
"total_count": 3,
"page_no": 1,
"ret_msg": "Operation successful",
"ret_code": "000000",
"page_count": 1,
"page_size": 15
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# ● Query knowledge details
API type: Active call API
API function: The knowledge details can be queried by calling this interface.
Request method: POST
Request URL:
http://sg.sobot.io/ai-agent-open/api/kb/query_knowledge_info
Request param:
Name | Type | Required | Description |
---|---|---|---|
docid | String | Yes | Knowledge id |
Return param:
Name | Type | Required | Description |
---|---|---|---|
ret_code | String | / | Return code |
ret_msg | String | / | Return message |
data | Object | / | Return object |
Data object:
Name | Type | Required | Description |
---|---|---|---|
kbid | Integer | / | Knowledge base id |
save_type | String | / | Save type 1-Published 0-Draft |
timezone | String | / | Time zone |
language | String | / | Language |
doc_type | Integer | / | Knowledge type 1-Article, 2-Question, 3-File |
question_title | String | / | Title |
rule_status | String | / | Rule status |
update_name | String | / | Updater name |
rule_desc_and_list | Array | / | AND rule list description |
rule_desc_or_list | Array | / | OR rule list |
update_time | Long | / | Update time |
companyid | String | / | Company id |
default_lan_flag | String | / | Default language flag 1-Default 0-Non-default |
createid | String | / | Creator id |
sub_doc | Array | / | Existing language entries |
create_time | Long | / | Creation time |
rule_name | String | / | Rule name |
cover | String | / | Cover link |
answer_info | Array | / | Answer content |
file_name | String | / | File name |
docid | String | / | Entry id |
question_typeid | String | / | Directory id |
file_size | Integer | / | File size |
effect_status | Integer | / | Effective status 0-Permanently effective, 1-Custom time |
updateid | String | / | Updater id |
dataid | String | / | Data main id, Used to distinguish a group of multilingual term identifiers |
used_flag | Integer | / | Knowledge status 0-Enabled, 1-Disabled, 2-Initialized |
ruleid | String | / | Rule id |
create_name | String | / | Creator name |
Request example:
curl http://sg.sobot.io/ai-agent-open/api/kb/query_knowledge_info
-X POST
-H 'token:cdc94901834c4190adbde1810d2d3a58'
-H 'content-type: application/json'
-d '
{
"docid": "b50d3cf526544e6a8ee5f7cd621b485c"
}'
2
3
4
5
6
7
8
Return example
{
"data": {
"kbid": 32,
"similar_questions": [],
"save_type": "1",
"timezone": "Asia/Shanghai",
"reset_section_flag": "1",
"language": "zh-Hans",
"question_status": 0,
"doc_type": 3,
"question_title": "test111222222",
"rule_status": "UPDATE",
"update_name": "HonLia",
"rule_desc_and_list": [
"Channel source belongs to Desktop website, All"
],
"update_time": 1753467955670,
"companyid": "039fe9e7e2e24f8b8685f4ce5edef3e2",
"default_lan_flag": 1,
"createid": "6a2fce77ad1a4051bf74254cf9c3c393",
"sub_doc": [],
"questionid": "fad0600cdc5f4040a0e6b51a1a303f1d",
"create_time": 1751015106277,
"rule_name": "Add a rule",
"answer_info": [
{
"answerid": "9a0a8e992aec41b980035472b7fe1960",
"answer": "https://img-test.sobot.com/039fe9e7e2e24f8b8685f4ce5edef3e2/common/test_1751015095246.pdf",
"answer_txt": "https://img-test.sobot.com/039fe9e7e2e24f8b8685f4ce5edef3e2/common/test_1751015095246.pdf",
"answer_status": 0
}
],
"file_name": "test.pdf",
"docid": "b50d3cf526544e6a8ee5f7cd621b485c",
"batchid": "4f04b920cd8a4fa9b0785f2253f49d5d",
"question_typeid": "776be87dedfa41a28fc92bd9b82cf99a",
"file_size": 89332,
"effect_status": 0,
"updateid": "6a2fce77ad1a4051bf74254cf9c3c393",
"dataid": "90c5ab873afd414da61b8c77e48f9140",
"section_error_case": "",
"used_flag": 0,
"ruleid": "b17f3bf60f0340dcb3d23f657117a32b",
"section_status": "SECTION_SUCCESS",
"create_name": "HonLia"
},
"ret_msg": "Operation successful",
"ret_code": "000000"
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# ● Add knowledge - Question, Article
API type: Active call API
API function: Questions and articles can be added by calling this interface.
Request method: POST
Request URL:
http://sg.sobot.io/ai-agent-open/api/kb/save_knowledge
Request param:
Name | Type | Required | Description |
---|---|---|---|
kbid | Integer | Yes | Knowledge base id |
question_title | String | Yes | Title |
question_typeid | String | Yes | Knowledge base classification id |
save_type | Integer | Yes | Save type 1-Published 0-Draft |
answer_info | Array | Yes | Content |
doc_type | Integer | Yes | Knowledge type 1-Article, 2-Question, 3-File |
used_flag | Integer | Yes | Knowledge status 0-Enabled, 1-Disabled |
effect_status | Integer | Yes | Effective status 0-Permanently effective, 1-Custom time |
language | String | Yes | language |
default_lan_flag | Integer | Yes | Default language flag 1-Default 0-Non-default |
timezone | String | Yes | Time zone |
dataid | String | No | Data main id, Used to distinguish a group of multilingual term identifiers |
cover | String | No | Cover link |
effect_time | Long | No | Custom effective time |
invalid_time | Long | No | Custom expiration time |
ruleid | String | No | Rule id |
rule_name | String | No | Rule name |
Return param:
Name | Type | Required | Description |
---|---|---|---|
ret_code | String | / | Return code |
ret_msg | String | / | Return message |
data | Object | / | Return object |
Data object:
Name | Type | Required | Description |
---|---|---|---|
dataid | String | / | Data main id, Used to distinguish a group of multilingual term identifiers |
Request example:
curl http://sg.sobot.io/ai-agent-open/api/kb/save_knowledge
-X POST
-H 'token:cdc94901834c4190adbde1810d2d3a58'
-H 'content-type: application/json'
-d '
{
"kbid": 32,
"questionid": null,
"question_title": "A big wave",
"question_typeid": "30a8c5a16f6541b381acf3da706e312e",
"answer_info": [
{
"answer": "<p>Content part 01</p>"
}
],
"doc_type": 2,
"used_flag": 0,
"effect_status": 0,
"language": "zh-Hans",
"similar_questions": [
{}
],
"save_type": 1,
"default_lan_flag": 1,
"cover": null,
"timezone": "Asia/Shanghai",
"ruleid": "ALL",
"rule_name": null
}'
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
Return example
{
"data": {
"dataid": "7dcdb79928cf4127b8d1db7fa12e9cdd"
},
"ret_msg": "Operation successful",
"ret_code": "000000"
}
2
3
4
5
6
7
# ● Add knowledge - Upload files
API type: Active call API
API function: Files can be uploaded in batches to add knowledge by calling this interface.
Request method: POST
Request URL:
http://sg.sobot.io/ai-agent-open/api/kb/batch_upload
Request param:
Name | Type | Required | Description |
---|---|---|---|
kbid | Integer | Yes | Knowledge base id |
file_info_list | Array | Yes | Uploaded file information |
question_typeid | String | Yes | Knowledge base classification id |
save_type | Integer | Yes | Save type 1-Published 0-Draft |
answer_info | Array | Yes | Content |
doc_type | Integer | Yes | Knowledge type 1-Article, 2-Question, 3-File |
used_flag | Integer | Yes | Knowledge status 0-Enabled, 1-Disabled |
effect_status | Integer | Yes | Effective status 0-Permanently effective, 1-Custom time |
language | String | Yes | language |
default_lan_flag | Integer | Yes | Default language flag 1-Default 0-Non-default |
timezone | String | Yes | Time zone |
effect_time | Long | No | Custom effective time |
invalid_time | Long | No | Custom expiration time |
ruleid | String | No | Rule id |
rule_name | String | No | Rule name |
File_info_list object:
Name | Type | Required | Description |
---|---|---|---|
question_title | String | Yes | File title |
file_name | String | Yes | File name |
file_size | String | Yes | File size |
file_url | String | Yes | File path |
Return param:
Name | Type | Required | Description |
---|---|---|---|
ret_code | String | / | Return code |
ret_msg | String | / | Return message |
Request example:
curl http://sg.sobot.io/ai-agent-open/api/kb/batch_upload
-X POST
-H 'token:cdc94901834c4190adbde1810d2d3a58'
-H 'content-type: application/json'
-d '
{
"language": "zh-Hans",
"used_flag": 0,
"effect_status": 0,
"timezone": "Asia/Shanghai",
"ruleid": "ALL",
"question_typeid": "19bd5a5293334b5697a96e756b22f6e7",
"kbid": 32,
"save_type": 1,
"file_info_list": [
{
"question_title": "test3454567e567",
"file_name": "test.pdf",
"file_size": 89332,
"file_url": "https://img-test.sobot.com/039fe9e7e2e24f8b8685f4ce5edef3e2/common/test_1753772820171.pdf"
}
],
"default_lan_flag": 1,
"doc_type": 3
}'
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
Return example
{
"ret_msg": "Operation successful",
"ret_code": "000000"
}
2
3
4
# ● Modify Question, Article or File
API type: Active call API
API function: Questions, articles or files can be modified by calling this interface.
Request method: POST
Request URL:
http://sg.sobot.io/ai-agent-open/api/kb/update_knowledge
Request parameters:
Parameter | Type | Required | Description |
---|---|---|---|
kbid | Integer | Yes | Knowledge base id |
question_typeid | String | Yes | Knowledge base classification id |
questionid | String | Yes | Standard question id |
docid | String | Yes | Entry id |
dataid | String | Yes | Data main id, Used to distinguish a group of multilingual term identifiers |
save_type | Integer | Yes | Save type 1-Published 0-Draft |
answer_info | Array | Yes | Content |
doc_type | Integer | Yes | Knowledge type 1-Article, 2-Question, 3-File |
used_flag | Integer | Yes | Knowledge status 0-Enabled, 1-Disabled |
effect_status | Integer | Yes | Effective status 0-Permanently effective, 1-Custom time |
language | String | Yes | Language |
default_lan_flag | Integer | Yes | Default language flag 1-Default 0-Non-default |
timezone | String | Yes | Time zone |
effect_time | Long | No | Custom effective time |
invalid_time | Long | No | Custom expiration time |
ruleid | String | No | Rule id |
rule_name | String | No | Rule name |
similar_questions | Array | No | Similar questions |
file_name | String | No | File name |
file_size | String | No | File size |
question_title | String | No | Title |
question_type_name | String | No | Directory name |
rule_status | String | No | Rule status ENABLE/DELETE/STOP/UPDATE |
Answer_info object:
Parameter | Type | Required | Description |
---|---|---|---|
answerid | String | Yes | Answer id |
answer | String | Yes | Answer |
Return parameters:
Parameter | Type | Required | Description |
---|---|---|---|
ret_code | String | / | Return code |
ret_msg | String | / | Return message |
data | Object | / | Return data |
Request example:
curl http://sg.sobot.io/ai-agent-open/api/kb/update_knowledge
-X POST
-H 'token:cdc94901834c4190adbde1810d2d3a58'
-H 'content-type: application/json'
-d '
{
"docid": "22b2f3eda27f4e60bd98dfd6268d9455",
"dataid": "d9610a99f7da4c47ba4642592ad4ef77",
"kbid": 1,
"questionid": "ed2c683027324ffa8135c2c52647f1e7",
"question_title": "How to turn off installation detection on Huawei phones",
"question_typeid": "d78197ccf0fc4870ac2343e5463e2b4b",
"answer_info": [
{
"answerid": "369cff59e50248f1b711546df154c59d",
"answer": "<p>Method 1: Turn off through system settings<br>Enter the phone [Settings] - [Security and Privacy] or directly select [Security]. Find the [More Security Settings] or [App Scan] option. Turn off [External Source App Check] or [App Installation Scan]</p>",
"answers": null,
"answer_txt": "Method 1: Turn off through system settings Enter the phone [Settings] - [Security and Privacy] or directly select [Security]. Find the [More Security Settings] or [App Scan] option. Turn off [External Source App Check] or [App Installation Scan]",
"answer_status": 0,
"rich_list": null
}
],
"doc_type": 2,
"used_flag": 0,
"effect_status": 0,
"language": "zh-Hans",
"similar_questions": [{}],
"save_type": 1,
"default_lan_flag": 1,
"cover": null,
"timezone": "Asia/Shanghai",
"ruleid": "ALL",
"rule_name": null
}'
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
Return example:
{
"data": {
"dataId": "d9610a99f7da4c47ba4642592ad4ef77"
},
"retCode": "000000",
"retMsg": "Operation successful"
}
2
3
4
5
6
7
# ● Batch delete knowledge
API type: Active call API
API function: Knowledge can be deleted in batches by calling this interface.
Request method: POST
Request URL:
http://sg.sobot.io/ai-agent-open/api/kb/batch_delete_knowledge
Request param:
Name | Type | Required | Description |
---|---|---|---|
docid_list | Array | Yes | Knowledge id collection |
Return param:
Name | Type | Required | Description |
---|---|---|---|
ret_code | String | / | Return code |
ret_msg | String | / | Return message |
Request example:
curl http://sg.sobot.io/ai-agent-open/api/kb/batch_delete_knowledge
-X POST
-H 'token:cdc94901834c4190adbde1810d2d3a58'
-H 'content-type: application/json'
-d '
{
"docid_list": [
"a9c7bac90fbb411794ccc64eea1f64d8",
"ac66e9be1ba14ddbbbe0ad4cd14678cf"
]
}'
2
3
4
5
6
7
8
9
10
11
Return example
{
"ret_msg": "Operation successful",
"ret_code": "000000"
}
2
3
4
# Error Codes
# ● Operation successful
Error Code | Error Description |
---|---|
000000 | Operation successful(Except for this code, all other codes are error codes) |
# ● System Exception
Error Code | Error Description |
---|---|
900001 | Token is empty |
900002 | Token has expired, please reacquire |
900003 | signature error |
900004 | No company API configuration information found |
999999 | System unknown exception |
# ● Business Exception
Error Code | Error Description |
---|---|
120037 | Similar question count cannot exceed 1000 |
120039 | Please set the effective time of knowledge first |
120035 | Cannot enable knowledge outside the set effective time range |
120034 | Entry question or answer cannot be empty |
120451 | Rule invalid |
999994 | Parameter exception, please check |
120319 | Upload file count cannot exceed 100 |
120048 | Classification names at the same level cannot be duplicated |
120305 | File name cannot be empty |
120304 | Upload file path cannot be empty |
120051 | No entry data found |
120049 | Deletion failed because there are entries under the original classification |