Improving performance by creating tickets asynchronously

If you create tickets in Zendesk Support with the API but want faster response times in your application, you can instruct the API to queue the jobs and just return a ticket ID and information about the status of the job.

You enable this option by adding anasync=truequery string parameter to theCreate Ticketendpoint URL. Example:

             
curl https://{subdomain}.亚博.com/api/v2/tickets.json?async=true\-d'{"ticket": ... }'\-H"Content-Type: application/json"\-v-u{email_address}:{password}-XPOST

The quicker response will contain theidof the ticket to be created as well as ajob_statusobject that you can inspect. The response won't contain any other ticket information.

Creating tickets takes a long time because the system has to run each ticket through all your triggers and save data to a database before it knows what the full response looks like.

You won't be able to fetch the ticket until the job is done. There's a possibility the background job will fail and the ticket won't be created. To ensure the ticket was created, check to see if the job status is "completed", or if the ticket exists.

To check the job status

  1. Retrieve the job statusidfrom the response to the asynchronous request.

  2. Use the statusidto make a request to theShow Job Statusendpoint:

                   
    curl https://{subdomain}.亚博.com/api/v2/job_statuses/{id}.json \-v-u{email_address}:{password}
  3. Verify thestatusproperty in the response.

    The status can be one of the following: "queued", "working", "failed", "completed", or "killed".

To check if the ticket exists

  1. Retrieve the job statusidfrom the response to the asynchronous request.

  2. Use the ticketidto make a request to theShow Ticketendpoint:

                   
    curl https://{subdomain}.亚博.com/api/v2/tickets/{id}.json \-v-u{email_address}:{password}
  3. Verify the response.

    If the ticket was successfully created, you'll get the full ticket response back. If it hasn't been created yet, or if it failed to be created, you'll get a 404 Not Found error.