Tickets 工单(客服)接口
此接口提供给客服人员,用来查看和处理工单
若是普通用户角色操作工单,请查看 工单(普通用户) 接口 Requests API
JSON格式
Name | Type | Read-only | Mandatory | Comment |
---|---|---|---|---|
id | integer | yes | no | 创建工单时系统自动分配 |
url | string | yes | no | 此工单的url地址 |
title | string | no | no | 标题 |
description | string | yes | no | 工单描述,即第一条工单回复的文本内容 |
type | string | no | no | 类型:"problem", "incident", "question", "task" |
status | string | no | no | 状态:"new","open", "pending", "solved", "closed" |
priority | string | no | no | 优先级:"low", "medium", "high", "urgent" |
recipient | string | yes | no | 邮件工单的原收件人地址 |
requester_id | integer | no | yes | 发起人id |
assignee_id | integer | no | no | 受理客服id |
organization_id | integer | yes | no | 发起人所属公司组织id |
group_id | integer | no | no | 受理客服组id |
problem_id | integer | no | no | incident工单所关联的problem工单的id |
due_date | date | no | no | task工单的截止时间 |
created_at | date | yes | no | 创建时间 |
updated_at | date | yes | no | 最后更新时间 |
assigneed_at | date | yes | no | 首次被受理时间 |
resolved_at | date | yes | no | 工单被解决时间 |
closed_at | date | yes | no | 工单被关闭时间 |
source | string | yes | no | 工单来源:"web", "tab", "chat", "email", "mobile", "weibo", "api" |
collaborator_ids | array | no | no | 副本用户数组 |
tags | array | no | no | 标签数组 |
custom_fields | array | no | no | 工单自定义字段 |
satisfaction_rating | object | yes | no | 满意度评价 |
JSON示例
{
"id": 8,
"url": "https://support.kf5.com/apiv2/tickets/8.json",
"title": "hello world",
"description": "wonderful world",
"type": null,
"status": "solved",
"priority": "low",
"recipient": null,
"requester_id": 738,
"assignee_id": 733,
"organization_id": null,
"group_id": 165,
"problem_id": null,
"due_date": null,
"created_at": "2014-06-12 17:25:40",
"updated_at": "2014-07-04 15:04:51",
"assigneed_at": "2014-06-15 00:00:00",
"resolved_at": "2014-07-04 15:04:51",
"closed_at": null,
"source": "web",
"collaborator_ids": [ ],
"tags": [ "TAG测试","TAG测试1" ],
"custom_fields": [
{
"name": "field_8",
"value": "1213"
},
{
"name": "field_36",
"value": "下拉菜单选项"
}
],
"satisfaction_rating": {
"id": 16,
"score": "Great",
"comment": "great service!"
}
}
工单列表
GET /apiv2/tickets.json
Query参数
Name | Required | Type | Comment |
---|---|---|---|
created_start | 否 | string | 按创建时间筛选,开始时间 |
created_end | 否 | string | 按创建时间筛选,结束时间 |
updated_start | 否 | string | 按更新时间筛选,开始时间 |
updated_end | 否 | string | 按更新时间筛选,结束时间 |
created_order | 否 | string | 按创建时间排序,可选值:asc、desc |
updated_order | 否 | string | 按更新时间排序,可选值:asc、desc |
status_order | 否 | string | 按工单状态排序,可选值:asc、desc |
field_order | 否 | string | 按工单自定义字段排序,参数格式:field_690_asc 或 field_690_desc,field_690 为字段名, 可以通过 工单自定义字段接口 获得 |
page | 否 | number | 页码,默认为 1 |
per_page | 否 | number | 分页尺寸,默认为 100 |
备注: 分页返回所有工单,默认排序为按编号升序排列。 按创建和更新时间进行筛选的参数 created_start、created_end、updated_start、updated_end,支持日期格式(如 2016-01-01 00:00:00)和时间戳(秒级别的整型)。 |
调用权限
admin
也可以使用如下API:
查看指定客服受理的工单
GET /apiv2/users/{user_id}/tickets.json
Note: 客服查看工单列表请使用 Views API
curl示例
curl https://{subdomain}.kf5.com/apiv2/tickets.json \
-v -u {email_address}:{password}
返回示例
Status: 200 OK
{
"tickets": [
{
"id": 1,
"title": "您好,您有一个工单需要处理",
...
},
{
"id": 2,
"title": "您好,您还有一个工单需要处理",
...
}
]
}
查看工单
GET /apiv2/tickets/{id}.json
调用权限
agent
curl示例
curl https://{subdomain}.kf5.com/apiv2/tickets/{id}.json \
-v -u {email_address}:{password}
返回示例
Status: 200 OK
{
"ticket": {
"id": 1,
"title": "admin 您好,您有一个测试工单需要处理",
...
}
}
查看多个工单
GET /apiv2/tickets/show_many.json?ids={ids}
最多返回100条数据
调用权限
agent
curl示例
curl https://{subdomain}.kf5.com/apiv2/tickets/show_many.json?ids={ids} \
-v -u {email_address}:{password}
返回示例
请参照 工单列表
创建工单
POST /apiv2/tickets.json
调用权限
agent
curl示例
curl https://{subdomain}.kf5.com/apiv2/tickets.json \
-d '{"ticket":{"title":"the title", "comment": { "content": "the content" }}}' \
-H "Content-Type: application/json" -v -u {email_address}:{password} -X POST
返回示例
Status: 201 Created
Location: https://{subdomain}.kf5.com/apiv2/tickets/{id}.json
{
"ticket": {
{
"id": 123,
"title": "the title",
...
}
}
}
请求参数
Name | Type | Required | Description |
---|---|---|---|
title | string | yes | 标题 |
comment | object | yes | 工单描述,请参考 Ticket Comments API |
requester_id | integer | no | 发起人id,新用户提交工单时请用requeter参数, 不填则默认为当前客服id |
requester | object | no | 发起人信息,请参照下方requester参数示例 此字段可与requester_id二选一,requester_id优先。 |
assignee_id | integer | no | 受理客服id |
group_id | integer | no | 受理客服组id |
type | string | no | 可选值:"problem", "incident", "question", "task" |
status | string | no | 可选值:"new","open", "pending", "solved", "closed" |
priority | string | no | 可选值:"low", "medium", "high", "urgent" |
problem_id | integer | no | 类型为incident时,关联的故障工单id |
due_at | date | no | 类型为task时,截止日期 |
tags | array | no | 要给工单添加的标签数组 |
collaborator_ids | array | no | 副本用户数组 |
custom_fields | array | no | 工单自定义字段 |
新用户提交工单
可设置requester字段值为用户的邮箱或者手机号,若该用户邮箱或者手机号在系统里不存在,则系统将会在工单创建时自动创建此用户
"requester": "newuser@mail.com"
"requester": "18613210119"
requester多个参数格式示例
可以传递的参数有email,phone,name. 当email和phone同时存在时,以email为主来创建用户,其他两个参数作为可填项传给创建的用户。
"requester":{
"email": "pablito@example.org",
"phone": 18613210119,
"name": "new user"
}
创建工单示例请求
{
"ticket":{
"title": "Let's create ticket",
"comment": { "content": "what are you waiting for?" },
"requester":{ "email": "pablito@example.org", "name": "new user"},
"type": "problem"
}
}
设置自定义字段
Note: 请注意自定义字段的类型验证规则,想了解更多请看 工单自定义字段接口 Ticket Fields API
"custom_fields": [{"name": "field_123", "value": "test"}, ...]
上传工单附件
在创建或者更新工单时,可以给工单回复添加附件。首先需要调用 Attachments API 里的上传附件接口, 成功后会返回附件token,然后将token添加到comment里的uploads数组里,这样工单回复在保存时就能把附件给关联上。
"comment": {
"content": "with attachments",
"uploads": ["00154af5872418a7792dda", ...]
}
更新工单
PUT /apiv2/tickets/{id}.json
调用权限
agent
curl示例
curl https://{subdomain}.kf5.com/apiv2/tickets/{id}.json \
-H "Content-Type: application/json" \
-d '{"ticket":{"status":"solved", \
"comment":{"public":true, "content": "Thanks, this is now solved!"}}}' \
-v -u {email_address}:{password} -X PUT
返回示例
Status: 200 OK
{
"ticket": {
"id": 123,
"title": "Let's create ticket",
"status": "solved",
...
}
}
请求参数
Name | Type | Description |
---|---|---|
title | string | 标题 |
comment | object | 工单回复,请参考 Ticket Comments API |
assignee_id | integer | 受理客服id |
group_id | integer | 受理客服组id |
type | string | 可选值:"problem", "incident", "question", "task" |
status | string | 可选值:"new","open", "pending", "solved", "closed" |
priority | string | 可选值:"low", "medium", "high", "urgent" |
problem_id | integer | 类型为incident时,关联的故障工单id |
due_at | date | 类型为task时,截止日期 |
tags | array | 要给工单添加的标签数组 |
collaborator_ids | array | 副本用户数组 |
custom_fields | array | 工单自定义字段 |
示例请求
{
"ticket":{
"comment": { "content":"thank you","public":"true" },
"status": "solved"
}
}
更新多个工单
PUT /apiv2/tickets/update_many.json?ids={ids}
Note: 一次操作最多更新100个工单
调用权限
agent
curl示例
curl https://{subdomain}.kf5.com/apiv2/tickets/update_many.json?ids=1,2 \
-H "Content-Type: application/json" -d "{\"ticket\":{\"status\":\"solved\"}}" \
-v -u {email_address}:{password} -X PUT
返回示例
Status: 200 OK
{
"results": [
{
"id": 1,
"success": false,
"errors": "状态为已解决时,受理人不能为空"
},
{
"id": 2,
"success": true,
"errors": ""
}
]
}
示例请求
{
"ticket": {
"status": "solved"
}
}
删除工单
DELETE /apiv2/tickets/{id}.json
调用权限
admin
curl示例
curl https://{subdomain}.kf5.com/apiv2/tickets/{id}.json \
-v -u {email_address}:{password} -X DELETE
返回示例
Status: 200 OK
删除多个工单
DELETE /apiv2/tickets/delete_many.json?ids={ids}
调用权限
admin
curl示例
curl https://{subdomain}.kf5.com/apiv2/tickets/destroy_many.json?ids=1,2,3 \
-v -u {email_address}:{password} -X DELETE
返回示例
Status: 200 OK
搜索工单
GET /apiv2/tickets/search.json
调用权限
admin
agent
请求参数
query: 查询关键词,模糊查询多个字段
status: 状态筛选条件
fieldvalue: 自定义字段条件
created_order: 搜索结果按创建时间排序,可选值:asc,desc (默认为desc)
请求示例
GET /apiv2/tickets/search.json?query=iphone6
GET /apiv2/tickets/search.json?status=open,solved
获取含有自定义字段值为12345的工单列表
GET /apiv2/tickets/search.json?fieldvalue=12345
返回示例
Status: 200 OK
{
"tickets": [
{
"id": 33,
"status": "open",
"title": "here is a bug",
...
},
{
"id": 34,
"status": "closed",
"title": "here is another bug",
...
}
]
}
工单可用的副本用户
GET /apiv2/tickets/{id}/collaborators.json
调用权限
agent
curl示例
curl https://{subdomain}.kf5.com/apiv2/tickets/{id}/collaborators.json \
-v -u {email_address}:{password}
返回示例
Status: 200
{
"users": [
{
"id": 100,
"name": "客服1号",
...
},
{
"id": 101,
"name": "客服2号",
...
}
]
}
工单被关联的事务列表
GET /apiv2/tickets/{id}/incidents.json
调用权限
agent
curl示例
curl https://{subdomain}.kf5.com/apiv2/tickets/{id}/incidents.json \
-v -u {email_address}:{password}
返回示例
Status: 200 OK
{
"tickets": [
{
"id": 33,
"subject": "service 503",
"status": "open",
...
},
{
"id": 34,
"subject": "503 service",
"status": "pending",
...
},
]
}
故障类型的工单列表
GET /apiv2/tickets/problems.json
调用权限
agent
curl示例
curl https://{subdomain}.kf5.com/apiv2/tickets/problems.json \
-v -u {email_address}:{password}
返回示例
Note: 默认按最后更新时间倒序排列
Status: 200 OK
{
"tickets": [
{
"id": 32,
"subject": "503 service",
"status": "open",
...
},
{
"id": 90,
"subject": "here is a bug",
"status": "pending",
...
},
]
}