logo

Knowledge Base Category Interface

knowledge_type values

English Name
question
useful_expression
useful_link
attachment

Create Different Knowledge Base Categories

This interface is used to create different types of knowledge base categories.

Request Method

POST /knowledge_catalogs

Request Parameters (Request Body)

Parameter NameTypeRequiredDescriptionRestrictions
knowledge_catalogObjectYesKnowledge base parametersNone

The structure of knowledge_catalog is as follows:

Parameter NameTypeRequiredDescriptionRestrictions
nameStringYesName of the knowledge baseNo more than 255 characters
knowledge_type_nameStringYesEnglish name from knowledge_typeNone
parent_idIntegerNoID of the parent categoryNone
agent_idIntegerYesCustomer service IDNone
Notes:
  • knowledge_type_name: Only the four values from knowledge_type are supported.
  • agent_id: The value is the customer service ID or 0, where 0 represents the administrator. The owner of the newly created category is the customer service corresponding to the agent_id. Other ordinary customer services do not have permission to operate this category. If the value of agent_id is 0, the administrator is the owner of the new category.
  • parent_id: If the parameter does not include parent_id, a top-level category is created by default; if a subcategory needs to be created, the parameter must be passed, and its value is the ID of the parent category. In the example, write any integer for the value of parent_id, but it cannot be empty.

Return Data

Attribute NameTypeDescription
codeIntegerExecution result code, 1000 means success
nameStringName of the new category
idIntegerID of the new category

Example

Request

curl https://demo.udesk.cn/open_api_v1/knowledge_catalogs?email=admin@udesk.cn&timestamp=1494474404&sign=6892f1b794071c260e1b1eac15df588fc919c9e86eb742affaa742ad6c03cb52&nonce=2d931510-d99f-494a-8c67-87feb05e1594&sign_version=v2 \
-X POST \
-H 'content-type: appliacation/json' \
-d '
{
    "knowledge_catalog": {
        "knowledge_type_name": "question",
        "name": "Question library 1",
        "agent_id":0,
        "parent_id": ""
    }
}
'

Result

{
    "code": 1000,
    "id": 22,
    "name": "Question library 1"
}

Modify Different Knowledge Base Categories

This interface is used to modify existing different types of knowledge base categories.

Request Method

PUT /knowledge_catalogs/:id

Request Parameters (URL)

Parameter NameTypeRequiredDescriptionRestrictions
idIntegerYesCategory IDNone

Request Parameters (Request Body)

Parameter NameTypeRequiredDescriptionRestrictions
knowledge_catalogObjectYesKnowledge base parametersNone

The structure of knowledge_catalog is as follows:

Parameter NameTypeRequiredDescriptionRestrictions
nameStringYesName of the knowledge baseNo more than 255 characters
agent_idIntegerYesCustomer service IDNone
Notes:
  • agent_id: Specific customer service ID or 0, where 0 represents the administrator.
  • Only the owner of the category has the permission to make changes. If the customer service corresponding to the agent_id passed in the parameter is not the same person as the owner of the category, the modification cannot be made.

Return Data

Attribute NameTypeDescription
codeIntegerExecution result code, 1000 means success
nameStringName of the new category
idIntegerID of the modified category

Example

Request

curl https://demo.udesk.cn/open_api_v1/knowledge_catalogs/11?email=admin@udesk.cn&timestamp=1494474404&sign=6892f1b794071c260e1b1eac15df588fc919c9e86eb742affaa742ad6c03cb52&nonce=2d931510-d99f-494a-8c67-87feb05e1594&sign_version=v2 \
-X PUT \
-H 'content-type: appliacation/json' \
-d '
{
    "knowledge_catalog": {
        "name": "Frequently used links",
        "agent_id": 0
    }
}
'

Result

{
    "code": 1000,
    "id": 11,
    "name": "Frequently used links"
}

Delete Different Knowledge Base Categories

This interface is used to delete existing different types of knowledge base categories.

Request Method

DELETE /knowledge_catalogs/:id

Request Parameters (URL)

Parameter NameTypeRequiredDescriptionRestrictions
idIntegerYesCategory IDNone

Request Parameters (Request Body)

Parameter NameTypeRequiredDescriptionRestrictions
knowledge_catalogObjectYesKnowledge base parametersNone

The structure of knowledge_catalog is as follows:

Parameter NameTypeRequiredDescriptionRestrictions
agent_idIntegerYesCustomer service IDNone
Notes:
  • agent_id: Specific customer service ID or 0, where 0 represents the administrator.
  • Only the owner of the category has the permission to delete. If the customer service corresponding to the agent_id passed in the parameter is not the same person as the owner of the category, the deletion cannot be made.

Return Data

Attribute NameTypeDescription
codeIntegerExecution result code, 1000 means success
idIntegerID of the deleted category
messageStringInformation about deleting the category

Example

Request

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

Result

{
    "code": 1000,
    "message": "Category delete success",
    "id": "19"
}

Get Different Knowledge Base Category Lists

This interface is used to get existing different types of knowledge base category lists.

Request Method

GET /knowledge_catalogs

Request Parameters (Request Body)

Parameter NameTypeRequiredDescriptionRestrictions
knowledge_type_nameStringYesEnglish name from knowledge_typeNone
agent_idIntegerYesCustomer service ID, default is the administratorNone
Notes:
  • agent_id: Specific customer service ID or 0, where 0 represents the administrator.
  • If the value of agent_id is a valid customer service ID, it will get the categories of a certain type of knowledge base for that customer service;
  • If the value of agent_id is 0, it will get the categories of a certain type of knowledge base for the administrator;

Return Data

Attribute NameTypeDescription
codeIntegerExecution result code, 1000 means success
catalogsArrayCategory list

The structure of catalogs is as follows:

Attribute NameTypeDescription
nameStringName of the category
idIntegerID of the category
parent_idIntegerParent ID of the category
childrenObjectSubcategories of the category

Example

Request

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

Result

{
    "code": 1000,
    "catalogs": [
        {
            "id": 4,
            "parent_id": 0,
            "name": "Common phrases 1"
        },
        {
            "id": 5,
            "parent_id": 0,
            "name": "Common phrases 2",
            "children": [
                {
                    "id": 6,
                    "parent_id": 5,
                    "name": "Common phrases 1-1"
                }
            ]
        }
    ]
}

Useful Expressions Interface

Get Useful Expressions List

This interface is used to get all or specified category useful expressions for a specific customer service.

Request Method

GET /useful_expressions

Request Parameters (Query String)

Parameter NameTypeRequiredDescriptionRestrictions
catalog_idIntegerYesUseful expression category id
agent_idIntegerYesID of the owner of the category
pageIntegerNoPage number, starting from 1, default is 1
per_pageIntegerNoNumber per page, default is 20, maximum is 100
Notes:
  • catalog_id: Specific category id or 0, where 0 represents all.
  • agent_id: Specific customer service ID or 0, where 0 represents the administrator.

Return Data

Attribute NameTypeDescription
codeIntegerExecution result code, 1000 means success
useful_expressionsArrayUseful expressions list
metaObjectPagination related content, see Common Data

The structure of useful_expressions is as follows:

Attribute NameTypeDescription
idIntegerUseful expression id
contentStringUseful expression content
catalog_idIntegerUseful expression category id

Example

Request

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

Response

{
    "code": 1000,
    "useful_expressions": [
        {
            "id": 1,
            "content": "content1",
            "catalog_id": 4
        },
        {
            "id": 2,
            "content": "content2",
            "catalog_id": 5
        },
        {
            "id": 3,
            "content": "content2",
            "catalog_id": 6
        },
        {
            "id": 4,
            "content": "content4",
            "catalog_id": 6
        }
    ],
    "meta": {
        "current_page": 1,
        "total_pages": 1,
        "total_count": 4
    }
}

Update Useful Expression

This interface is used to modify the content of a specific useful expression.

Request Method

PUT /useful_expressions/:id

Request Parameters (URL)

Parameter NameTypeRequiredDescriptionRestrictions
idIntegerYesUseful expression id

Request Parameters (Request Body)

Parameter NameTypeRequiredDescriptionRestrictions
contentStringYesUseful expression content
agent_idIntegerYesCreator's ID of the useful expression
Notes:
  • The value of agent_id is a specific customer service ID or 0, where 0 represents the administrator.

Return Data

Attribute NameTypeDescription
codeIntegerExecution result code, 1000 means success
idIntegerUseful expression id
contentStringUseful expression content

Example

Request

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

Response

{
    "code": 1000,
    "id": 4,
    "content": "content12",
    "catalog_id": 6
}

Add Useful Expression

This interface is used to create a new useful expression under a specific category of a specific customer service.

Request Method

POST /useful_expressions

Request Parameters (Request Body)

Parameter NameTypeRequiredDescriptionRestrictions
contentStringYesUseful expression content
catalog_idIntegerYesUseful expression category id
agent_idIntegerYesCreator's ID of the useful expression
Notes:
  • catalog_id: Specific category id.
  • agent_id: Specific customer service ID or 0, where 0 represents the administrator.

Return Data

Attribute NameTypeDescription
codeIntegerExecution result code, 1000 means success
idIntegerUseful expression id
contentStringUseful expression content
catalog_idIntegerUseful expression category id

Example

Request

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

Response

{
    "code": 1000,
    "id": 4,
    "content": "kakkakakakakakakaka",
    "catalog_id": 6
}

Delete Useful Expression

This interface is used to delete a specific useful expression.

Request Method

DELETE /useful_expressions/:id

Request Parameters (URL)

Parameter NameTypeRequiredDescriptionRestrictions
idIntegerYesUseful expression id

Request Parameters (Request Body)

Parameter NameTypeRequiredDescriptionRestrictions
agent_idIntegerYesCreator's ID of the useful expression

Return Data

Attribute NameTypeDescription
codeIntegerExecution result code, 1000 means success
idIntegerUseful expression id
messageStringResult description

Example

Request

curl https://demo.udesk.cn/open_api_v1/useful_expressions/4?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,
    "message": "Useful expression deleted successfully",
    "id": 4
}

This interface is used to retrieve all or specified category common links under a certain customer service.

Request Method

GET /useful_links

Request Parameters (Query String)

Parameter NameTypeRequiredDescriptionRestrictions
catalog_idIntegerYesCommon link category id
agent_idIntegerYesThe id of the owner of the common link 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, 0 represents all
  • agent_id: The specific customer service id or 0, 0 represents the administrator

Return Data

Attribute NameTypeDescription
codeIntegerExecution result code, 1000 represents success
useful_linksArrayCommon link list
metaObjectPagination related content, see Common Data

Data Structure of useful_links

Attribute NameTypeDescription
idIntegerCommon link id
nameStringCommon link name
urlStringCommon link address
catalog_idIntegerCommon link category id

Example

Request

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

Response

{
    "code": 1000,
    "useful_links": [
        {
            "id": 6,
            "name": "Link 6",
            "url": "https://www.baidu1.com",
            "catalog_id": 11
        },
        {
            "id": 8,
            "name": "Link 8",
            "url": "https://www.baidu1.com",
            "catalog_id": 11
        },
        {
            "id": 9,
            "name": "Link 9",
            "url": "https://www.baidu1.com",
            "catalog_id": 11
        },
        {
            "id": 10,
            "name": "Link 10",
            "url": "https://www.baidu1.com",
            "catalog_id": 11
        },
        {
            "id": 11,
            "name": "Link 11",
            "url": "https://www.baidu1.com",
            "catalog_id": 11
        }
    ],
    "meta": {
        "current_page": 1,
        "total_pages": 1,
        "total_count": 5
    }
}

This interface is used to modify a specific common link.

Request Method

PUT /useful_links/:id

Request Parameters (URL)

Parameter NameTypeRequiredDescriptionRestrictions
idIntegerYesCommon link id

Request Parameters (Request Body)

Parameter NameTypeRequiredDescriptionRestrictions
nameStringNoCommon link content
urlStringNoCommon link address
agent_idIntegerYesThe id of the creator of the common link
Notes:
  • The value of agent_id is the specific customer service id or 0, 0 represents the administrator
  • In a single request, the common link name and common link address cannot be empty at the same time

Return Data

Attribute NameTypeDescription
codeIntegerExecution result code, 1000 represents success
idIntegerCommon link id
nameStringCommon link name
urlStringCommon link address
catalog_idIntegerCommon link category id

Example

Request

curl https://demo.udesk.cn/open_api_v1/useful_links/12?email=admin@udesk.cn&timestamp=149447&sign=6892f1b794071c260e1b1eac15df588fc919c9e86eb742affaa742ad6c03cb52&nonce=2d931510-d99f-494a-8c67-87feb05e1594&sign_version=v2 \
-X PUT \
-H 'content-type: appliacation/json' \
-d '
{
"name": "",
"url": "https://www.bai.com",
"agent_id": 4
}'

Response

{
    "code": 1000,
    "id": 12,
    "name": "name",
    "url": "https://www.bai.com",
    "catalog_id": 12
}

This interface is used to create a new common link under a certain customer service's common link category.

Request Method

POST /useful_links

Request Parameters (Request Body)

Parameter NameTypeRequiredDescriptionRestrictions
nameStringYesCommon link name
urlStringYesCommon link address
catalog_idIntegerYesCommon link category id
agent_idIntegerYesThe id of the creator of the common link
Notes:
  • catalog_id: The specific category id, there is no category with id 0
  • agent_id: The specific customer service id or 0, 0 represents the administrator

Return Data

Attribute NameTypeDescription
codeIntegerExecution result code, 1000 represents success
idIntegerCommon link id

Example

Request

curl https://demo.udesk.cn/open_api_v1/useful_expressions?email=admin@udesk.cn&timestamp=1494474404&sign=6892f1b794071c260e1b1eac15df588fc919c9e86eb742affaa742ad6c03cb52&nonce=2d931510-d99f-494a-8c67-87feb05e1594&sign_version=v2 \
-X POST \
-H 'content-type: appliacation/json' \
-d '
{
  "name": "Link 10",
  "url": "https://www.baidu1.com",
  "catalog_id": 12,
  "agent_id": 4
}
'

Response

{
    "code": 1000,
    "id": 12,
    "name": "Link 10",
    "url": "https://www.baidu1.com",
    "catalog_id": 12
}

This interface is used to delete a specific common link.

Request Method

DELETE /useful_links/:id

Request Parameters (URL)

Parameter NameTypeRequiredDescriptionRestrictions
idIntegerYesCommon link id

Request Parameters (Request Body)

Parameter NameTypeRequiredDescriptionRestrictions
agent_idIntegerYesThe id of the creator of the common link

Return Data

Attribute NameTypeDescription
codeIntegerExecution result code, 1000 represents success
idIntegerCommon link id
messageStringResult explanation

Example

Request

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

Response

{
    "code": 1000,
    "id": "7",
    "message": "Common link deleted successfully"
}

Knowledge Base API

  • Questions are time-sensitive. When lasts is true, the values of last_min and last_max are meaningless; when lasts is false, the values of last_min and last_max are meaningful.

Get Knowledge Base Questions List

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

Request Method

GET /knowledge_questions

Request Parameters (Query String)

Parameter NameTypeRequiredDescriptionRestrictions
catalog_idIntYesCategory ID
agent_idIntYesOwner ID
pageIntNoPage number, starts from 1, default is 1
per_pageIntNoNumber per page, default is 20, max is 100
Notes:
  • catalog_id: Specific category ID or 0 or -1, 0 represents all, -1 represents uncategorized.
  • agent_id: Specific customer service ID or 0, 0 represents the administrator.

Return Data

Attribute NameTypeDescription
codeIntExecution result code, 1000 means success
knowledge_questionsArrayKnowledge base questions list
metaObjectPagination related content, see Common Data

Data structure of knowledge_questions

Attribute NameTypeDescription
idIntKnowledge base question ID
titleStringKnowledge base question name
contentStringKnowledge base question answer
content_typeStringKnowledge base question answer type
catalog_idIntCategory ID
updated_atDateTimeLast update time of the question
lastsBooleanWhether the question is permanently valid
last_minDateTimeLower limit of question validity
last_maxDateTimeUpper limit of question validity

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": "question content",
            "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": "demo title",
            "content": "demo content",
            "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
    }
}

Update Knowledge Base

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

Request Method

PUT /knowledge_questions/:id

Request Parameters (URL)

Parameter NameTypeRequiredDescriptionRestrictions
idIntYesQuestion ID

Request Parameters (Request Body)

Parameter NameTypeRequiredDescriptionRestrictions
questionObjectYesSpecific question values

Data structure of question

Parameter NameTypeRequiredDescriptionRestrictions
agent_idIntYesCreator's ID
contentStringNoQuestion answer
titleStringNoQuestion name
content_typeStringNoQuestion answer type
lastsBooleanYesIs the question permanently valid
last_minDateTimeNoLower limit of question validity
last_maxDateTimeNoUpper limit of question validity
Notes:
  • The value of agent_id is a specific customer service ID or 0, where 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
codeIntExecution result code, 1000 means success
idIntKnowledge base ID
titleStringKnowledge base question name
content_typeStringKnowledge base question content type
contentStringKnowledge base question content
lastsBooleanIs the knowledge base question permanently valid
last_minDateTimeLower limit of knowledge base question validity
last_maxDateTimeUpper limit of knowledge base question validity

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: appliacation/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"
}

Add Knowledge Base Question

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

Request Method

POST /knowledge_questions

Request Parameters (Request Body)

Parameter NameTypeRequiredDescriptionRestrictions
questionObjectYesSpecific question values

Data structure of question

Parameter NameTypeRequiredDescriptionRestrictions
agent_idIntYesCreator's ID
contentStringYesQuestion answer
titleStringYesQuestion name
content_typeStringYesQuestion answer type
catalog_idIntYesCategory ID
lastsBooleanYesIs the question permanently valid
last_minDateTimeNoLower limit of question validity
last_maxDateTimeNoUpper limit of question validity
Notes:
  • catalog_id: Specific category ID or 0 or -1, 0 represents all, -1 represents uncategorized.
  • agent_id: Specific customer service ID or 0, where 0 represents the administrator.

Return Data

Attribute NameTypeDescription
codeIntExecution result code, 1000 means success
idIntKnowledge base ID

Example

Request

curl https://demo.udesk.cn/open_api_v1/useful_expressions?email=admin@udesk.cn&timestamp=1494474404&sign&sign_version=v2 \
-X POST \
-H 'content-type: appliacation/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
}

Delete Knowledge Base Question

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

Request Method

DELETE /knowledge_questions/:id

Request Parameters (URL)

Parameter NameTypeRequiredDescriptionRestrictions
idIntYesQuestion ID

Request Parameters (Request Body)

Parameter NameTypeRequiredDescriptionRestrictions
agent_idIntYesCreator's ID

Return Data

Attribute NameTypeDescription
codeIntExecution result code, 1000 means success
idIntKnowledge 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: appliacation/json' \
-d '
{
  "agent_id": 0
}
'

Response

{
    "code": 1000,
    "id": "8",
    "message": "question delete success"
}

Attachment Library API

Get Attachment Library List

This interface is used to get the list of attachments under a certain customer service or specified category.

Request Method

GET /knowledge_attachments

Request Parameters (Query String)

Parameter NameTypeRequiredDescriptionRestrictions
catalog_idIntYesCategory ID
agent_idIntYesOwner ID
pageIntNoPage number, starts from 1, default is 1
per_pageIntNoNumber per page, default is 20, max is 100
Notes:
  • catalog_id: Specific category ID or 0, 0 represents all.
  • agent_id: Specific customer service ID or 0, 0 represents the administrator.

Return Data

Attribute NameTypeDescription
codeIntExecution result code, 1000 means success
knowledge_attachmentsArrayAttachment list
metaObjectPagination related content, see Common Data

Data structure of knowledge_attachments

Attribute NameTypeDescription
idIntAttachment ID
file_nameStringAttachment name
file_typeStringAttachment type
file_sizeStringAttachment size
file_urlStringAttachment URL
catalog_idIntCategory ID of attachment

Example

Request

curl https://demo.udesk.cn/open_api_v1/knowledge_attachments?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_attachments": [
        {
            "id": 1,
            "catalog_id": 9,
            "file_name": "JPG.JPG",
            "file_type": "image/jpeg",
            "file_size": null,
            "file_url": "https://qn-public.udesk.cn/1472632419-JPG.JPG"
        },
        {
            "id": 2,
            "catalog_id": 10,
            "file_name": "JPG.JPG",
            "file_type": "image/jpeg",
            "file_size": null,
            "file_url": "https://qn-public.udesk.cn/JPG.JPG"
        },
        {
            "id": 3,
            "catalog_id": null,
            "file_name": "file.docx",
            "file_type": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
            "file_size": "11858",
            "file_url": "https://qn-public.udesk.cn/Fs65I3NAYnqt_URMYQB8NAwerWI3"
        }
    ],
    "meta": {
        "current_page": 1,
        "total_pages": 1,
        "total_count": 3
    }
}

Re-Upload Attachment

This interface is used to modify a specific attachment.

Request Method

PUT /knowledge_attachments/:id

Request Parameters (URL)

Parameter NameTypeRequiredDescriptionRestrictions
idIntYesAttachment ID
file_nameStringYesAttachment file name
typeStringYesAttachment file type
agent_idIntYesAttachment creator's ID
Notes:
  • agent_id's value is a specific customer service ID or 0, where 0 represents the administrator.
  • In the request, specify Content-type:application/octet-stream, upload the file as a stream file in the request body.
  • Please ensure the correctness of the file type type, otherwise the file cannot be recognized.

Return Data

Attribute NameTypeDescription
idIntAttachment ID
file_nameStringAttachment name
file_typeStringAttachment type
file_sizeStringAttachment size
file_urlStringAttachment URL
catalog_idIntCategory ID of attachment

Example

Request

curl https://demo.udesk.cn/open_api_v1/knowledge_attachments?email=admin@udesk.cn&timestamp=1494474404&sign=6892f1b794071c260e1b1eac15df588fc919c9e86eb742affaa742ad6c03cb52&nonce=2d931510-d99f-494a-8c67-87feb05e1594&sign_version=v2&file_name=aaa&type=jpg&agent_id=0&catalog_id=10 \
-X PUT \
-H 'content-type: appliacation/json' \
-d '
'

Response

{
    "code": 1000,
    "id": 5,
    "catalog_id": 10,
    "file_name": "9747.jpg_wh300.jpg",
    "file_type": "jpg",
    "file_size": 79044,
    "file_url": "https://qn-public.udesk.cn/Fk8NQDfDUqbImbZvD37VVDejCNfv"
}

Add New Attachment

This interface is used to create a new attachment under a certain customer service's category.

Request Method

POST /knowledge_attachments

Request Parameters (Request URL)

Parameter NameTypeRequiredDescriptionRestrictions
file_nameStringYesAttachment name
typeStringYesAttachment file type
catalog_idIntYesAttachment category ID
agent_idIntYesAttachment creator's ID
Notes:
  • catalog_id: Specific category ID.
  • agent_id: Specific customer service ID or 0, where 0 represents the administrator.
  • In the request, specify Content-type:application/octet-stream, upload the file as a stream file in the request body.
  • Please ensure the correctness of the file type type, otherwise the file cannot be recognized.

Return Data

Attribute NameTypeDescription
idIntAttachment ID
file_nameStringAttachment name
file_typeStringAttachment type
file_sizeStringAttachment size
file_urlStringAttachment URL
catalog_idIntCategory ID of attachment

Example

Request

curl https://demo.udesk.cn/open_api_v1/knowledge_attachments?email=admin@udesk.cn&timestamp=1494474404&sign=6892f1b794071c260e1b1eac15df588fc919c9e86eb742affaa742ad6c03cb52&nonce=2d931510-d99f-494a-8c67-87feb05e1594&sign_version=v2&file_name=aaa&type=jpg&agent_id=0&catalog_id=10 \
-X POST \
-H 'content-type: appliacation/json' \
-d '
'

Response

{
    "code": 1000,
    "id": 4,
    "catalog_id": 10,
    "file_name": "9747.jpg_wh300.jpg",
    "file_type": "jpg",
    "file_size": 79044,
    "file_url": "https://qn-public.udesk.cn/Fk8NQDfDUqbImbZvD37VVDejCNfv"
}

Delete Attachment

This interface is used to delete a specific attachment.

Request Method

DELETE /knowledge_attachments/:id

Request Parameters (URL)

Parameter NameTypeRequiredDescriptionRestrictions
idIntYesAttachment ID
agent_idIntYesAttachment creator's ID

Return Data

Attribute NameTypeDescription
codeIntExecution result code, 1000 means success
idIntAttachment ID
messageStringResult description

Example

Request

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

Response

{
    "code": 1000,
    "id": "4111",
    "message": "Attachment delete success"
}

Error Code Description

Error CodeMessage InformationException:message InformationDescription
2000agent_id is a required fieldThe agent_id field was not filled in the parameters.
agent_id must be an integerThe agent_id parameter is not an integer.
The category does not existThere is no category with the id \{catelog_id\}.
The category does not exist under the agent's nameThe category with id {catelog_id} does not belong to the agent with id {agent_id} and cannot be modified.
catalog_id is a required fieldThe {catelog_id} parameter cannot be empty.
catalog_id must be an integerThe value of {catelog_id} in the parameters must be an integer.
The resource was not foundNo data was found with the corresponding id.
The link category does not exist under the agent's nameThe frequently used link category with id {catelog_id} does not belong to the agent with id {agent_id}.
Unknown errorAn unknown error occurred.
knowledge_type_name value is incorrectThe value of parameter {knowledge_type_name} is incorrect.
Verification failed: Name cannot be an empty stringThe value of parameter {name} cannot be empty.
Verification failed: Parent does not belong to the same categoryThe category with id {parent_id} was not found under the {knowledge_type_name} type.
Cannot create a category as there is content under the parent categoryThe category with id {parent_id} is not a leaf node (has other data).
A maximum of four levels of categories can be createdThe category with id {parent_id} is a fourth-level category (the knowledge base category allows a maximum of 4 levels).
Verification failed: Name is already in useThere is a subcategory with the same name as {name} under the category with id {parent_id}.
The administrator's existing category does not have a subcategory with id {parent_id}The category with id {parent_id} does not exist.
param is missing or the value is empty: knowledge_catalogThe parameter is missing the object {knowledge_catalog}.
The content content of the frequently used phrase cannot be emptyThe value of content in the parameters cannot be empty.
You have not set the content to be modifiedWhen modifying the frequently used link, at least one of the name or url parameters must have a value.
The name name of the frequently used link is a required fieldThe value of name in the parameters cannot be empty.
The URL url of the frequently used link is a required fieldThe value of url in the parameters cannot be empty.
param is missing or the value is empty: questionThe parameter is missing the question object.
The value of content_type is incorrectThe value of the content_type parameter can only be text or html.
The validity period lasts of the question cannot be emptyThe value of lasts in the parameters cannot be empty, it must be true/false.
The format of last_min is incorrectWhen the value of lasts is false, the value of last_min must follow the date format and cannot be empty.
The format of last_max is incorrectWhen the value of lasts is false, the value of last_max must follow the date format and cannot be empty.
last_max cannot be less than or equal to last_minWhen the value of lasts is false, the value of last_max must be less than or equal to the value of last_min.
content cannot be emptyThe value of content in the parameters cannot be empty.
title cannot be emptyThe value of titlein the parameters cannot be empty.
content_type cannot be emptyThe value of content_type in the parameters cannot be empty.
The value of the validity period lasts of the question is incorrectThe value of lasts in the parameters cannot be empty, it must be true/false.
The upper and lower limits of the validity period of the question cannot be emptyThe values of last_min and last_max in the parameters cannot be empty.
file_name is a required field and cannot be emptyThe value of file_name in the parameters cannot be empty.
type is a required field and cannot be emptyThe value of type in the parameters cannot be empty.
2005The resource was not foundActiveRecord::RecordNotFoundThe parameter \{id\} did not match any data.