Ticket Import

You can use the imports API to move tickets in bulk from legacy systems into Zendesk Support.

Ticket imports support the normal ticket properties outlined inTickets, but have some additional features and restrictions.

Timestamps

You can set the following time stamps on the tickets:solved_at,updated_at, andcreated_at. However, providing a value forcreated_atorupdated_atbefore 1970 will be automatically rounded up to 1970.

Comments

You can include one or more comments with a ticket. SeeTicket Commentsfor the properties. You can usevalue,body, orhtml_bodyfor the comment body. You can also set the comment'screated_attime stamp. However, you can't set the time stamp before 1970 or in the future.

Direct to archive

Ticket imports support the additional request parameter ofarchive_immediately. If true, any ticket created with aclosedstatus bypasses the normal ticket lifecycle and will be created directly in your ticket archive. It's important to note that archived tickets have a handful of restrictions around their use.You can read more about it here.

You may want to explore this option if you are importing a large amount of historical data (750,000+ tickets) and don't want to impact the performance of your active tickets.

Attachments

Attachments are handled the same way as in the tickets API. You upload the files then supply the token in the comment parameters. SeeAttaching files.

Triggers

No triggers are run on the imported tickets. As a result, there won't be any detailed ticket metrics for the tickets. Zendesk recommends setting a tag to signify that these tickets were added to Zendesk Support using import.

Notifications

No notifications are sent to users cc'ed on the imported tickets. Notifications are sent on subsequent updates to the tickets.

Ticket Import

  • POST /api/v2/imports/tickets

Allowed For

  • Admins

Parameters

Name Type In Required Description
archive_immediately boolean 查询 false Iftrue, any ticket created with aclosedstatus bypasses the normal ticket lifecycle and will be created directly in your ticket archive

Example body

             
{"ticket":{"assignee_id":19,"comments":[{"author_id":827,"created_at":"2009-06-25T10:15:18Z","value":"This is a comment"},{"author_id":19,"public":false,"value":"This is a private comment"}],"description":"A description","requester_id":827,"subject":"Help","tags":["foo","bar"]}}

代码示例

cURL
              
curlhttps://{subdomain}.亚博zendesk.com/api/v2/imports/tickets.json\-v -u{email_address}:{password}-X POST\-d”{"ticket": {"subject": "Help", "comments": [{ "author_id": 19, "value": "This is a comment" }]}}'\-H"Content-Type: application/json"
Go
              
import(“fmt”"io""net/http""strings")funcmain(){url:="https://example.zendesk.com/api/v2/imports/tickets?archive_immediately="method:="POST"payload:=strings.NewReader(`{"ticket": {"assignee_id": 19,"comments": [{"author_id": 827,"created_at": "2009-06-25T10:15:18Z","value": "This is a comment"},{"author_id": 19,"public": false,"value": "This is a private comment"}],"description": "A description","requester_id": 827,"subject": "Help","tags": ["foo","bar"]}}`)req,err:=http.NewRequest(method,url,payload)iferr!=nil{fmt.Println(err)return}req.Header.Add("Content-Type","application/json")req.Header.Add("Authorization","Basic ")// Base64 encoded "username:password"client:=&http.Client{}res,err:=client.Do(req)iferr!=nil{fmt.Println(err)return}deferres.Body.Close()body,err:=io.ReadAll(res.Body)iferr!=nil{fmt.Println(err)return}fmt.Println(string(body))}
Java
              
importcom.squareup.okhttp.*;OkHttpClientclient=newOkHttpClient();HttpUrl.BuilderurlBuilder=HttpUrl.parse("https://example.zendesk.com/api/v2/imports/tickets").newBuilder().addQueryParameter("archive_immediately","");RequestBodybody=RequestBody.create(MediaType.parse("application/json"),"""{\"ticket\":{\"assignee_id\":19,\"comments\":[{\"author_id\":827,\"created_at\":\"2009-06-25T10:15:18Z\",\"value\":\"Thisisa comment\"},{\"author_id\":19,\"public\":false,\"value\":\"Thisisaprivatecomment\"}],\"description\":\"Adescription\",\"requester_id\":827,\"subject\":\"Help\",\"tags\":[\"foo\",\"bar\"]}}""");Requestrequest=newRequest.Builder().url(urlBuilder.build()).method("POST",body).addHeader("Content-Type","application/json").addHeader("Authorization",Credentials.basic("your-email","your-password")).build();Responseresponse=client.newCall(request).execute();
Nodejs
              
varaxios=require('axios');vardata=JSON.stringify({"ticket":{"assignee_id":19,"comments":[{"author_id":827,"created_at":"2009-06-25T10:15:18Z","value":"This is a comment"},{"author_id":19,"public":false,"value":"This is a private comment"}],"description":"A description","requester_id":827,"subject":"Help","tags":["foo","bar"]}});varconfig={method:'POST',url:'https://example.zendesk.com/api/v2/imports/tickets',headers:{'Content-Type':'application/json','Authorization':'Basic ',// Base64 encoded "username:password"},params:{'archive_immediately':'',},data:data,};axios(config).then(function(response){console.log(JSON.stringify(response.data));}).catch(function(error){console.log(error);});
Python
              
importrequestsimportjsonurl="https://example.zendesk.com/api/v2/imports/tickets?archive_immediately="payload=json.loads("""{"ticket": {"assignee_id": 19,"comments": [{"author_id": 827,"created_at": "2009-06-25T10:15:18Z","value": "This is a comment"},{"author_id": 19,"public": false,"value": "This is a private comment"}],"description": "A description","requester_id": 827,"subject": "Help","tags": ["foo","bar"]}}""")headers={"Content-Type":"application/json",}response=requests.request("POST",url,auth=('',''),headers=headers,json=payload)print(response.text)
Ruby
              
require"net/http"uri=URI("https://example.zendesk.com/api/v2/imports/tickets")uri.query=URI.encode_www_form("archive_immediately":"")request=Net::HTTP::Post.new(uri,"Content-Type":"application/json")request.body=%q({"ticket":{"assignee_id":19,"comments":[{"author_id":827,"created_at":"2009-06-25T10:15:18Z","value":"This is a comment"},{"author_id":19,"public":false,"value":"This is a private comment"}],"description":"A description","requester_id":827,"subject":"Help","tags":["foo","bar"]}})request.basic_auth"username","password"response=Net::HTTP.start uri.hostname,uri.port,use_ssl:truedo|http|http.request(request)end

Example response(s)

201 Created
              
// Status 201 Created{"ticket":{"assignee_id":235323,"collaborator_ids":[35334,234],"created_at":"2009-07-20T22:55:29Z","custom_fields":[{"id":27642,"value":"745"},{"id":27648,"value":"yes"}],"custom_status_id":123,"description":"The fire is very colorful.","due_at":null,"external_id":"ahg35h3jh","follower_ids":[35334,234],"from_messaging_channel":false,"group_id":98738,"has_incidents":false,"id":35436,"organization_id":509974,"priority":"high","problem_id":9873764,"raw_subject":"{{dc.printer_on_fire}}","recipient":"[email protected]","requester_id":20978392,"satisfaction_rating":{"comment":"Great support!","id":1234,"score":"good"},"sharing_agreement_ids":[84432],"status":"open","subject":"Help, my printer is on fire!","submitter_id":76872,"tags":["enterprise","other_tag"],"type":"incident","updated_at":"2011-05-05T10:38:52Z","url":"https://company.zendesk.com/api/v2/tickets/35436.json","via":{"channel":"web"}}}

Ticket Bulk Import

  • POST /api/v2/imports/tickets/create_many

Accepts an array of up to 100 ticket objects.

Allowed For

  • Admins

Example Response

This endpoint returns ajob_statusJSON objectand queues a background job to do the work. Use theShow Job Statusendpoint to check for the job's completion.

Parameters

Name Type In Required Description
archive_immediately boolean 查询 false Iftrue, any ticket created with aclosedstatus bypasses the normal ticket lifecycle and will be created directly in your ticket archive

Example body

             
{"tickets":[{"assignee_id":19,"comments":[{"author_id":827,"created_at":"2009-06-25T10:15:18Z","value":"This is a comment"},{"author_id":19,"public":false,"value":"This is a private comment"}],"description":"A description","requester_id":827,"subject":"Help","tags":["foo","bar"]},{"assignee_id":21,"comments":[{"author_id":830,"created_at":"2009-06-25T10:15:18Z","value":"This is a comment"},{"author_id":21,"public":false,"value":"This is a private comment"}],"description":"A description","requester_id":830,"subject":"Missing Item","tags":["foo","bar"]}]}

代码示例

cURL
              
curlhttps://{subdomain}.亚博zendesk.com/api/v2/imports/tickets/create_many.json\-v -u{email_address}:{password}-X POST\-d”{"tickets": [{"subject": "Help!", "comments": [{ "author_id": 19, "value": "This is a comment" }]}, {"subject": "Help!!", "comments": [{ "author_id": 21, "value": "This is a comment" }]}]}'\-H"Content-Type: application/json"
Go
              
import(“fmt”"io""net/http""strings")funcmain(){url:="https://example.zendesk.com/api/v2/imports/tickets/create_many?archive_immediately="method:="POST"payload:=strings.NewReader(`{"tickets": [{"assignee_id": 19,"comments": [{"author_id": 827,"created_at": "2009-06-25T10:15:18Z","value": "This is a comment"},{"author_id": 19,"public": false,"value": "This is a private comment"}],"description": "A description","requester_id": 827,"subject": "Help","tags": ["foo","bar"]},{"assignee_id": 21,"comments": [{"author_id": 830,"created_at": "2009-06-25T10:15:18Z","value": "This is a comment"},{"author_id": 21,"public": false,"value": "This is a private comment"}],"description": "A description","requester_id": 830,"subject": "Missing Item","tags": ["foo","bar"]}]}`)req,err:=http.NewRequest(method,url,payload)iferr!=nil{fmt.Println(err)return}req.Header.Add("Content-Type","application/json")req.Header.Add("Authorization","Basic ")// Base64 encoded "username:password"client:=&http.Client{}res,err:=client.Do(req)iferr!=nil{fmt.Println(err)return}deferres.Body.Close()body,err:=io.ReadAll(res.Body)iferr!=nil{fmt.Println(err)return}fmt.Println(string(body))}
Java
              
importcom.squareup.okhttp.*;OkHttpClientclient=newOkHttpClient();HttpUrl.BuilderurlBuilder=HttpUrl.parse("https://example.zendesk.com/api/v2/imports/tickets/create_many").newBuilder().addQueryParameter("archive_immediately","");RequestBodybody=RequestBody.create(MediaType.parse("application/json"),"""{\"tickets\":[{\"assignee_id\":19,\"comments\":[{\"author_id\":827,\"created_at\":\"2009-06-25T10:15:18Z\",\"value\":\"Thisisa comment\"},{\"author_id\":19,\"public\":false,\"value\":\"Thisisaprivatecomment\"}],\"description\":\"Adescription\",\"requester_id\":827,\"subject\":\"Help\",\"tags\":[\"foo\",\"bar\"]},{\"assignee_id\":21,\"comments\":[{\"author_id\":830,\"created_at\":\"2009-06-25T10:15:18Z\",\"value\":\"Thisisa comment\"},{\"author_id\":21,\"public\":false,\"value\":\"Thisisaprivatecomment\"}],\"description\":\"Adescription\",\"requester_id\":830,\"subject\":\"MissingItem\",\"tags\":[\"foo\",\"bar\"]}]}""");Requestrequest=newRequest.Builder().url(urlBuilder.build()).method("POST",body).addHeader("Content-Type","application/json").addHeader("Authorization",Credentials.basic("your-email","your-password")).build();Responseresponse=client.newCall(request).execute();
Nodejs
              
varaxios=require('axios');vardata=JSON.stringify({"tickets":[{"assignee_id":19,"comments":[{"author_id":827,"created_at":"2009-06-25T10:15:18Z","value":"This is a comment"},{"author_id":19,"public":false,"value":"This is a private comment"}],"description":"A description","requester_id":827,"subject":"Help","tags":["foo","bar"]},{"assignee_id":21,"comments":[{"author_id":830,"created_at":"2009-06-25T10:15:18Z","value":"This is a comment"},{"author_id":21,"public":false,"value":"This is a private comment"}],"description":"A description","requester_id":830,"subject":"Missing Item","tags":["foo","bar"]}]});varconfig={method:'POST',url:'https://example.zendesk.com/api/v2/imports/tickets/create_many',headers:{'Content-Type':'application/json','Authorization':'Basic ',// Base64 encoded "username:password"},params:{'archive_immediately':'',},data:data,};axios(config).then(function(response){console.log(JSON.stringify(response.data));}).catch(function(error){console.log(error);});
Python
              
importrequestsimportjsonurl="https://example.zendesk.com/api/v2/imports/tickets/create_many?archive_immediately="payload=json.loads("""{"tickets": [{"assignee_id": 19,"comments": [{"author_id": 827,"created_at": "2009-06-25T10:15:18Z","value": "This is a comment"},{"author_id": 19,"public": false,"value": "This is a private comment"}],"description": "A description","requester_id": 827,"subject": "Help","tags": ["foo","bar"]},{"assignee_id": 21,"comments": [{"author_id": 830,"created_at": "2009-06-25T10:15:18Z","value": "This is a comment"},{"author_id": 21,"public": false,"value": "This is a private comment"}],"description": "A description","requester_id": 830,"subject": "Missing Item","tags": ["foo","bar"]}]}""")headers={"Content-Type":"application/json",}response=requests.request("POST",url,auth=('',''),headers=headers,json=payload)print(response.text)
Ruby
              
require"net/http"uri=URI("https://example.zendesk.com/api/v2/imports/tickets/create_many")uri.query=URI.encode_www_form("archive_immediately":"")request=Net::HTTP::Post.new(uri,"Content-Type":"application/json")request.body=%q({"tickets":[{"assignee_id":19,"comments":[{"author_id":827,"created_at":"2009-06-25T10:15:18Z","value":"This is a comment"},{"author_id":19,"public":false,"value":"This is a private comment"}],"description":"A description","requester_id":827,"subject":"Help","tags":["foo","bar"]},{"assignee_id":21,"comments":[{"author_id":830,"created_at":"2009-06-25T10:15:18Z","value":"This is a comment"},{"author_id":21,"public":false,"value":"This is a private comment"}],"description":"A description","requester_id":830,"subject":"Missing Item","tags":["foo","bar"]}]})request.basic_auth"username","password"response=Net::HTTP.start uri.hostname,uri.port,use_ssl:truedo|http|http.request(request)end

Example response(s)

200 OK
              
// Status 200 OK{"job_status":{"id":“82 de0b044094f0c67893ac9fe64f1a99”,"message":"Completed at 2018-03-08 10:07:04 +0000","progress":2,"results":[{"action":"update","id":244,"status":"Updated","success":true},{"action":"update","id":245,"status":"Updated","success":true}],"status":"completed","total":2,"url":"https://example.zendesk.com/api/v2/job_statuses/82de0b0467893ac9fe64f1a99.json"}}