In this 10-minute quickstart, you'll use the Zendesk API to create a few tickets.
To keep things moving along, you'll use the JavaScript console of your browser to make the API requests.
To authenticate the requests, you simply need to be signed in to your Zendesk Support account as an agent or admin on the same page as the JavaScript console.
Preparation
- If you don't already have a Zendesk Support account, register to start a free trial at https://www.zendesk.com/register/
- In your browser, navigate to your Zendesk account. The url will look something like
https://your_subdomain.zendesk.com
. -
Sign in, then open the agent interface by selecting Support from the product tray in the upper-right.
-
Click the Admin icon (
) in the sidebar, then select Channels > API, and make sure Password Access is enabled in the settings. If you don't have permissions to do this, ask an admin to check for you.
-
Make sure you're still in the agent interface, then open the browser's JavaScript console on the same page, as follows:
- Chrome: View > Developer > JavaScript Console
- Firefox: Tools > Web Developer > Web Console
- Safari: Develop > Show JavaScript Console. If you don't see the Develop menu, you'll need to turn it on in Safari preferences (Safari > Preferences, and click the Advanced tab).
It's important to open the console on the agent interface page or your API requests won't work.
Create some tickets
Let's create 3 tickets with one code snippet. To create a ticket with the API, you make a POST
request to the /api/v2/tickets.json
endpoint. You can find all the details about the Tickets API in the developer docs, but for now let's jump right in.
-
Paste the following script into your browser's console:
for(x=0; x<3; x++) { var subject = "Test ticket #" + x; var body = "This is test ticket #" + x; $.ajax({ url: '/api/v2/tickets.json', contentType:'application/json', type: 'POST', data: JSON.stringify({"ticket": {"subject": subject , "comment": { "body": body }}}) }) .done(function(data) { console.log(data.ticket); }); }
Here's what the code looks like after pasting it in the console in Google Chrome:
The code snippet creates a loop that makes 3 API requests.
-
Hit Enter.
Trouble?
- If you get
POST https://subdomain.zendesk.com/api/v2/tickets.json 404 (Not Found)
, it means you're not currently signed in to your account. Go do that now and retry. - If you get a
TypeError: $.ajax not a function
, it means you're not currently on the agent interface page. Open the agent interface, then open the JavaScript console on the same page, and give it another shot.
- If you get
-
If successful, you'll see the new tickets listed as objects in the console:
The last 3 objects are new tickets and all their information, including a bunch of properties you didn't bother to set. In the Chrome example above, you'd click the expander icon on the left of each object to see the rest of the properties.
Check out the properties you set yourself (
description
andsubject
), and ones the system set for you, such asstatus
. If you'd been so inclined, you could have set the ticket status yourself. Example (in bold):data: JSON.stringify({"ticket": {"subject": subject , "status": "open", "comment": { "body": body }}})
-
Switch to the agent interface to view your new tickets (click Views then Unassigned tickets):
When you're done trying out the API, delete the test tickets by selecting them in the list, clicking the Edit Tickets button in the upper-right, and selecting Delete.
Next steps
The best way to learn how to use the Zendesk API is to try different requests on your own. You can use any of the following resources along the way:
-
Learn about the most common tasks developers perform with the Zendesk API
-
Try tutorials and read articles in the API developer guide on the Zendesk Help Center
-
Peruse the extensive API reference documentation on the Zendesk developer portal
-
Run any of the examples in the reference docs using cURL, a lightweight, command-line tool for making HTTP requests without a web browser. See Installing and using cURL
-
Speed up development with an API client. An API client takes care of a lot of the low-level details of making requests and handling responses and lets you focus on the logic of your application
-
Ask questions or look for answers in the Zendesk API developer community.
13 Comments
Hi Charles,
When clicked on support it takes me nowhere.

Also when I try to entre
https://your_subdomain.zendesk.com it takes me to https://your_subdomain.zendesk.com\agent by default
could that be the issue?Hi Tejas-
From that screenshot it looks like you are already in the Support interface. If you are seeing
/agent
you're already authenticated into it.The script provided didn't run 3 instances, but ran non-stop until i manually stopped it, having it creating about 400(!!) tickets :(
That's odd Yair -- can you provide the exact script that you ran and the command line that ran it? Were there any modifications made? The above script samples is hard coded to run 3 times. Could the overall script itself have been run in a loop from the command line? Thanks for any additional info.
When to do the requests for token get 401 error { Error: Zendesk Error (401): Not Authorized
at checkRequestResponse (D:\click-eat-projects\clickeatweb\node_modules\node-zendesk\lib\client\client.js:259:13)
at requestCallback (D:\click-eat-projects\clickeatweb\node_modules\node-zendesk\lib\client\client.js:274:3)
at Request._callback (D:\click-eat-projects\clickeatweb\node_modules\node-zendesk\lib\client\client.js:111:5)
at Request.self.callback (D:\click-eat-projects\clickeatweb\node_modules\request\request.js:188:22)
at Request.emit (events.js:198:13)
Hi Umashankar Saw! Can you confirm that the credentials that you are using have sufficient privileges to make the request? If they were, we will likely need to investigate this further in a ticket, so let me know and we'll take if from there!
hola, me podrían mostrar algún ejemplo de descarga de información de chats usando php o java script?
Hi Gilberto Cota! We do have a PHP client that includes our Chat API. Hope that helps!
Hello,
I tried to make an API request to create tickets and new users on the fly...
I am getting CORS all the time.
Is it possible to do it with JS or a backend client is needed like PHP, Node, Java , etc.
Thank you.
Hi Alexis! Could you tell us more about how you're doing this? Is this a script that you have running, a ZAF app, requests from an API client like Postman, etc?
Hi Greg,
I have no issues creating tickets using Basic Auth with Postman, but moving this code to a vanilla js script I am blocked by CORS.
How to create tickets in Zendesk from another systems ?
Several marketplaces receive tickets from my customers. I want all these tickets to be sent to zendesk from the Marketplaces for centralized management in Zendesk.
How can I push these tickets to Zendesk ?
Alexis - Take a look at this article for assistance with CORS errors. This is not necessarily an unexpected outcome.
Ragheb - I responded to your other community post where you asked this question.
Please sign in to leave a comment.