创建工单
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 | 工单自定义字段 |
| template_id | integer | no | 工单模板ID |
新用户提交工单
可设置requester字段值为用户的邮箱或者手机号或者座机号(区号后面用"-"隔开,例如:028-1234569),若该用户邮箱或者手机号或者座机号在系统里不存在,则系统将会在工单创建时自动创建此用户
"requester": "newuser@mail.com"
"requester": "18613210119"
"requester": "028-1234569"
requester多个参数格式示例
可以传递的参数有email,phone,name. 当email和phone同时存在时,以email为主来创建用户,其他两个参数作为可填项传给创建的用户。
"requester":{
"email": "pablito@example.org",
"phone": 18613210119,
"landline": "028-1234569",
"name": "new user" }创建工单示例请求
{
"ticket":{
"title": "Let's create ticket",
"comment": {
"content": "what are you waiting for?",
"html_content": "the content",
"public": true,
"uploads": {"token":"0015ce392ec1919d564e63a46e54eb8"}
},
"requester": {
"name": "new user",
"email": "pablito@example.org"
},
"type": "problem",
"tags":["t1","t2"],
"due_at":"2019-04-09 18:00:10",
"custom_fields": [
{"name": "field_123", "value": "test"},
{"name": "field_567", "value": "world"}
]
}
}设置自定义字段
Note: 请注意自定义字段的类型验证规则,想了解更多请看 工单自定义字段接口 Ticket Fields API
"custom_fields": [{"name": "field_123", "value": "test"}, ...]上传工单附件
在创建或者更新工单时,可以给工单回复添加附件。首先需要调用 Attachments API 里的上传附件接口, 成功后会返回附件token,然后将token添加到comment里的uploads数组里,这样工单回复在保存时就能把附件给关联上。
"comment": {
"content": "with attachments",
"uploads": ["00154af5872418a7792dda", ...] }