logo

Getting the Knowledge Base Question List

This interface is used to get the list of knowledge base questions under a certain customer service, or under a specified category.

Request Method

GET /knowledge_questions

Request Parameters (Query String)

Parameter NameTypeRequiredDescriptionConstraints
catalog_idIntegerYesKnowledge base category id
agent_idIntegerYesThe id of the owner of the knowledge base category
pageIntegerNoPage number, starting from 1, default is 1
per_pageIntegerNoNumber of items per page, default is 20, maximum is 100
Notes:
  • catalog_id: The specific category id or 0 or -1, 0 represents all, -1 represents uncategorized.
  • agent_id: The specific customer service id or 0, 0 represents the administrator.

Return Data

Attribute NameTypeDescription
codeIntegerExecution result code, 1000 represents success
knowledge_questionsArrayKnowledge base question list
metaObjectPagination related content, see Common Data

knowledge_questions data structure

Attribute NameTypeDescription
idIntegerKnowledge base question id
titleStringKnowledge base question name
contentStringKnowledge base question answer
content_typeStringKnowledge base question answer type
catalog_idIntegerKnowledge base category id
updated_atDate TimeLast update time of the knowledge base question
lastsBooleanWhether the knowledge base question is permanently valid
last_minDate TimeLower limit of the validity period of the knowledge base question
last_maxDate TimeUpper limit of the validity period of the knowledge base question

Example

Request

curl https://demo.udesk.cn/open_api_v1/knowledge_questions?email=admin@udesk.cn&timestamp=1494474404&sign=6892f1b794071c260e1b1eac15df588fc919c9e86eb742affaa742ad6c03cb52&nonce=2d931510-d99f-494a-8c67-87feb05e1594&sign_version=v2&catalog_id=0&agent_id=0

Response

{
    "code": 1000,
    "knowledge_questions": [
        {
            "id": 1,
            "title": "Question 1",
            "content": "AAAAAAA",
            "content_type": "text",
            "lasts": true,
            "catalog_id": null,
            "updated_at": "2018-03-22T11:29:59.000+08:00",
            "last_min": null,
            "last_max": null
        },
        {
            "id": 3,
            "title": "Water Water",
            "content": "Water Water",
            "content_type": "text",
            "lasts": true,
            "catalog_id": 17,
            "updated_at": "2018-03-22T18:35:02.000+08:00",
            "last_min": "2018-03-31",
            "last_max": "2018-04-03"
        }
    ],
    "meta": {
        "current_page": 1,
        "total_pages": 1,
        "total_count": 2
    }
}

Updating the Knowledge Base

This interface is used to modify a specific knowledge base question.

Request Method

PUT /knowledge_questions/:id

Request Parameters (URL)

Parameter NameTypeRequiredDescriptionConstraints
idIntegerYesKnowledge base question id

Request Parameters (Request Body)

Parameter NameTypeRequiredDescriptionConstraints
questionObjectYesThe specific value of the question

question data structure

Parameter NameTypeRequiredDescriptionConstraints
agent_idIntegerYesThe id of the creator of the question
contentStringNoThe answer of the question
titleStringNoThe name of the question
content_typeStringNoThe type of the question answer
lastsBooleanYesWhether the knowledge base question is permanently valid
last_minDate TimeNoLower limit of the validity period of the knowledge base question
last_maxDate TimeNoUpper limit of the validity period of the knowledge base question
Notes:
  • The value of agent_id is the specific customer service id or 0, 0 represents the administrator.
  • If the value of content/title/content_type is "" or null, it is considered not to be modified.
  • The value of content_type is text/html.
  • When the value of lasts is true, the values of last_min and last_max are not saved.

Return Data

Attribute NameTypeDescription
codeIntegerExecution result code, 1000 represents success
idIntegerKnowledge base id
titleStringKnowledge base question name
content_typeStringKnowledge base question content type
contentStringKnowledge base content
lastsBooleanWhether the knowledge base question is permanently valid
last_minDate TimeLower limit of the validity period of the knowledge base question
last_maxDate TimeUpper limit of the validity period of the knowledge base question

Example

Request

curl https://demo.udesk.cn/open_api_v1/knowledge_questions/8?email=admin@udesk.cn&timestamp=1494474404&sign=6892f1b794071c260e1b1eac15df588fc919c9e86eb742affaa742ad6c03cb52&nonce=2d931510-d99f-494a-8c67-87feb05e1594&sign_version=v2 \
-X PUT \
-H 'content-type: application/json' \
-d '
{
    "question": {
        "agent_id": 0,
        "content": "asasasaasasadasass",
        "title": "",
        "content_type": "",
        "lasts": false,
        "last_min": "2018-03-31",
        "last_max": "2018-04-03"
    }
}
'

Response

{
    "code": 1000,
    "id": 8,
    "title": "title5",
    "content": "asasasaasasadasass",
    "content_type": "html",
    "catalog_id": null,
    "lasts": false,
    "last_min": "2018-03-31",
    "last_max": "2018-04-03"
}

Adding to the Knowledge Base

This interface is used to create a new knowledge base question under a certain customer service's specific knowledge base category.

Request Method

POST /knowledge_questions

Request Parameters (Request Body)

Parameter NameTypeRequiredDescriptionConstraints
questionObjectYesThe specific value of the question

question data structure

Parameter NameTypeRequiredDescriptionConstraints
agent_idIntegerYesThe id of the creator of the question
contentStringYesThe answer of the question
titleStringYesThe name of the question
content_typeStringYesThe type of the question answer
catalog_idIntegerYesKnowledge base category id
lastsBooleanYesWhether the knowledge base question is permanently valid
last_minDate TimeNoLower limit of the validity period of the knowledge base question
last_maxDate TimeNoUpper limit of the validity period of the knowledge base question
Notes:
  • catalog_id: The specific category id or 0 or -1, 0 represents all, -1 represents uncategorized.
  • agent_id: The specific customer service id or 0, 0 represents the administrator.

Return Data

Attribute NameTypeDescription
codeIntegerExecution result code, 1000 represents success
idIntegerKnowledge base id

Example

Request

curl https://demo.udesk.cn/open_api_v1/knowledge_questions?email=admin@udesk.cn&timestamp=1494474404&sign=6892f1b794071c260e1b1eac15df588fc919c9e86eb742affaa742ad6c03cb52&nonce=2d931510-d99f-494a-8c67-87feb05ee1594&sign_version=v2 \
-X POST \
-H 'content-type: application/json' \
-d '
{
    "question": {
        "agent_id": 0,
        "content": "asasasas",
        "title": "title1",
        "content_type": "html",
        "catalog_id":0,
        "lasts": true
    }
}
'

Response

{
    "code": 1000,
    "id": 8,
    "title": "title5",
    "content": "asasasas",
    "content_type": "html",
    "catalog_id": null,
    "lasts": true,
    "last_min": null,
    "last_max": null
}

Deleting from the Knowledge Base

This interface is used to delete a specific knowledge base question.

Request Method

DELETE /knowledge_questions/:id

Request Parameters (URL)

Parameter NameTypeRequiredDescriptionConstraints
idIntegerYesKnowledge base question id

Request Parameters (Request Body)

Parameter NameTypeRequiredDescriptionConstraints
agent_idIntegerYesThe id of the creator of the question

Return Data

Attribute NameTypeDescription
codeIntegerExecution result code, 1000 represents success
idIntegerKnowledge base id
messageStringSuccess message

Example

Request

curl https://demo.udesk.cn/open_api_v1/knowledge_questions/8?email=admin@udesk.cn&timestamp=1494474404&sign=6892f1b794071c260e1b1eac15df588fc919c9e86eb742affaa742ad6c03cb52&nonce=2d931510-d99f-494a-8c67-87feb05e1594&sign_version=v2 \
-X DELETE \
-H 'content-type: application/json' \
-d '
{
  "agent_id": 0
}
'

Response

{
    "code": 1000,
    "id": "8",
    "message": "Question deleted successfully"
}